Add an invalid #define for SDL_ThreadID() to SDL_oldnames.h#15801
Conversation
…dl-org#15749 in SDL2 SDL_ThreadID() was a function that's now SDL_GetCurrentThreadID(), but in SDL3 SDL_ThreadID is a type, so in C++ `x = SDL_ThreadID()` is valid code (default constructor which in case of integers means 0), so that's a massive footgun. See the big comment in SDL_oldnames.h for more details. Added `#undef SDL_ThreadID` in SDL_dynapi.c because it has one of the (quite rare) cases where "SDL_ThreadID" followed by a "(" is actually correct and necessary (function pointer returning SDL_ThreadID).
|
The failing GDK/MSVC test says BTW: I'm currently adding information about this to README-migration.md |
Yes, totally unrelated. The GDK version we're using on ci does not support Visual Studio 2026. |
|
Merged, thanks! I'm putting this in 3.6.0 so we can catch any more unexpected fallout from this. |
|
Here is the fallout: https://github.com/libsdl-org/sdl2-compat/actions/runs/27378527337/job/81120423041 |
…15801)" This reverts commit b04d026. This caused problems building sdl2-compat: https://github.com/libsdl-org/sdl2-compat/actions/runs/27378527337/job/81120423041
|
Yup, I went ahead and reverted this. |
|
Why did the CI builds triggered by the PR not catch this? |
|
Ah, the fallout is just in sdl2-compat.. Have you considered at least giving me a chance to fix such things before reverting the merged PR? :-p |
|
The solution is probably the same as what I did in SDL_dynapi.c in this PR: #ifdef SDL_ThreadID
/* prevent the SDL_ThreadID() define from conflicting
with the SDL_ThreadID() implementation here */
#undef SDL_ThreadID
#endif |
|
Or, maybe guard your define with |
|
Why would I leak SDL2-compat implementation details into SDL3? I clearly documented that this can lead to false positives in rare edge cases and showed up ways to work around those issues. I really don't get why the reaction to the first edge case having a problem (and implementing SDL2 with SDL3 definitely is an edge case) is to revert this instead of working around it in the edge case. |
The only purpose of |
|
Perhaps more generally useful (in case other projects want to do hacks with their own SDL_ThreadID defines) would be #ifndef SDL_ThreadID
#define SDL_ThreadID() SDL_ThreadID_is_a_type_now_function_is_SDL_GetCurrentThreadID
#endif |
|
Can't we disable |
good point, a anyway, next try (that should also solve the sdl2-compat problem): #15822 |
I haven't looked at this specific case, but we tend to revert breaks right away; it's not personal, fixes can be reapplied when ready, but until then the build is broken for everyone that might want to push unrelated fixes. It's not meant to be a rejection of the original concept or anything. |
I get this when the break happens in this repo, but elsewhere? And as I said, this change is expected to break edge cases, for the greater good of showing up (presumably much more common) broken code that uses Now my additional change fixes the specific edge case of sdl2-compat, but there are still other edge cases that can't be worked around here (but can relatively easy be worked around in user code).. |
* emscripten: dedupe keyboard event listeners across multiple windows * Update Famicom controllers to a more user friendly name. * iOS: Fix SDL_EVENT_DROP_FILE lost on cold start from URL open * examples/renderer/20-blending: center alpha and instructional text. Otherwise, it tends to get lost behind the "Source Code" tab in the web builds, if the browser window is too small. * examples/renderer/20-blending: Note when a blend mode is unsupported. * wayland: Handle captured pointer movements over a subsurface Some compositors will send pointer enter/leave event while moving between surfaces that are part of the same window while mouse capture is active. Maintain window focus in this case, and adjust the coordinates relative to the content surface by the subsurface offset, if necessary. * Fix casting errors * Remove CenterPad and RightStick from Steam Controller (2015) internal state struct These values are never used for the Steam Controller (2015), as it does not physically have these inputs. * wayland: Remove focus references when a pointer capture ends on a subsurface The core mouse code will unfocus the window when a capture ends outside the window boundaries, but the backend still needs to update the internal focus references. * SDL_itoa(): use _itoa_s(), not _ltoa_s() typo introduced by commit 33c9f1a * examples/demo/04-bytepusher: Remove render target. This doesn't need a render target to function. The comment suggested it was needed to make debug text look better when scaled, but maybe logical presentation used to do linear scaling exclusively at the time? * examples/demo/04-bytepusher: go back to showing help text on load failures. If the VM was already running, and then a file failed to open at all (a directory was dropped on the window, etc), this wouldn't go back to showing the help text. * Use SDL_PIXELFORMAT_INDEX8 for the debug font atlas * pdate openxr headers from khronos. * Add CYGWIN support for DLL library check (from libsdl-org/SDL_image#747) * Revert "SDL_itoa(): use _itoa_s(), not _ltoa_s()" This reverts commit ae07e32. This reverts commit 33c9f1a. * _uitoa does not exist * Use pragma to ignore deprecated integer-to-ascii CRT conversion functions * Fix buffer-overflow access in process_testStdinToStdout Backing memory of SDL_IOFromDynamicMem is not null-terminated. * Sync SDL3 wiki -> header [ci skip] * Sync SDL3 wiki -> header [ci skip] * opengles: Readd an OpenGL ES 1 renderer to SDL3! (libsdl-org#15185) This readds the "opengles" renderer, updated from SDL2 to work on SDL3. Fixes libsdl-org#15661. Co-authored-by: Ryan C. Gordon <icculus@icculus.org> Co-authored-by: Cameron Cawley <ccawley2011@gmail.com> * testgpurender_msdf: allow changing the text being rendered * add GLES headers from Khronos. * docs: Update notes on SDL_AudioStream format management. Fixes libsdl-org#15688. * Sync SDL3 wiki -> header [ci skip] * SVE2: Improves SVE2 8888 swizzling performance and important fixes (libsdl-org#15662) * SVE2 was actually disabled in fdfbbce, this issue is fixed - The macro __ARM_FEATURE_SVE is only defined when the compilation target is set as -march=armv8-m+sve2 * Improves 8888 alpha-blending performance - Now, in In-Order AArch64 processors, e.g. A520, SVE2 is better than NEON with the 128bit vector width - For Out-of-order processors, NEON is still better than SVE2 (We could improve this in the future), the performance is improved from 3.0 to 3.6. * The 8888 -> RGB565 performance is also improved (from 7.4 to 9.3) * Sync SDL3 wiki -> header [ci skip] * dos: Use INT 0x21, operation 0x62 to calculate basepath. Previously this captured argv[0] and pushed it through searchpath(). It's probably better to go right to the source to find this info, though. * Don't use the HIDAPI driver with Backbone One PlayStation Edition Gen 2 This product doesn't appear to use the DualSense protocol. On Android this shows up as two interfaces that don't send reports that we can parse. * video: Only ignore modes with a lower color depth in SDL_GetClosestFullscreenDisplayMode() If a mode with a closer refresh was found, but it had the same color depth as the current best match, it was being dropped. Only ignore the new mode if the color depth is below the current best match. * Android: Skip duplicated joystick axes during poll Resolves libsdl-org#15414 * filesystem: Added SDL_GetExeName(). core/unix had a more-limited copy of filesystem/unix's implementation, called SDL_GetExeName(). Replace that with a real implementation in filesystem, and allow each platform to implement it as appropriate. Implemented for Unix and Windows; most implementations are currently FIXME stubs at the moment. Reference Issue libsdl-org#15692. * metadata: SDL_GetAppMetadataProperty() now uses SDL_GetExeName(). (for SDL_PROP_APP_METADATA_NAME_STRING if unset. If SDL_GetExeName() returns NULL, it'll fallback to good ol' "SDL Application", as usual.) Fixes libsdl-org#15692. * xr: Add fallback for SDL_PROP_GPU_DEVICE_CREATE_XR_APPLICATION_NAME_STRING. It'll use SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING) if necessary now. * Ensure we release exclusive USB access to controllers when backgrounded. libsdl-org#15694 * GPU: Return early in SDL_WaitForGPUFences if num_fences is 0 * x11: SetupWindowData shouldn't add to videodata->windowlist until success. Fixes libsdl-org#15676. * x11: Fix boolean/enum comparison This could set the pending flag even if there was no state change requested, which would cause errant sync timeouts in certain situations. * docs: bump minimum required Android ndk version * gdk: Just use WIN_GetModulePath(). There's no need to use the "A" version of GetModuleFileName on GDK; it returns a UTF-8 string directly on this platform, but we can still use the UTF-16 "W" version and cut down on code duplication. This code runs once and caches the results, so we can take the one-time string conversion overhead. * filesystem: Implement SDL_GetExeName() for all platforms. * cmake: Preseed the CMake cache for Haiku OS. This change drops the configure time on my little Haiku virtual machine from 103 seconds to six. :) Fixes libsdl-org#15702. * Revert "android: fixed a possible joystick-related deadlock on application termination" This reverts commit 6b4ae68. It turns out this deadlock is possible for any joystick event delivery combined with an event watcher that locks joysticks. I'm reverting this change for now, and will be working on a better global solution for this problem. * GPU: Clarify some presentation concerns in docs (libsdl-org#15707) * Sync SDL3 wiki -> header [ci skip] * OpenVR: Actually quit correctly if we get a close/quit message. * Add support for new Steam Controller input report * Fix mistyped output report message for Steam Controller This caused hiccups in BlueZ BT driver for Linux * testcontroller: make sure touchpad touches are visible even at very light pressure * Add support for new Steam Controller input report on mobile devices * Fixed Steam Controller rumble on Android (thanks @Packetdancer!) * metal: fixed reading textures with format SDL_PIXELFORMAT_RGBA128_FLOAT * Added DEBUG_STEAM_PROTOCOL for the new Steam Controller * Added HIDAPI support for the PDP Afterglow Wave Wireless Controller for Switch * Fixed detecting the Steam virtual gamepad when HIDAPI is disabled * Fixed Steam Controller not detected on macOS under Steam * Android: Remove unused accelerometer-related code and definitions That also covers removal of the call `SDLActivity.onNativeAccel`, plus a change of comment under SDL_android.c. Definitions were previously used while an accelerometer could be listed as a joystick. * render: an empty clip rect should clip all drawing Added a test to validate this and fixed the Metal renderer Fixes libsdl-org#15434 * Send SDL_EVENT_WINDOW_EXPOSED when the GPU renderer swap chain is resized In this case the current frame being rendered doesn't match the swapchain size and the application should re-render the frame. Fixes libsdl-org#15550 * Added rumble to Gamecube Adapter PC_Mode (libsdl-org#15431) * wikiheaders: Fix manpages for APIs that return a pointer to a const object. Previously something like SDL_GetCurrentDisplayMode() would have this output: ``` RETURN VALUE *) Returns a pointer to the desktop display mode or NULL on failure; call SDL_GetError() for more information. ``` Now it doesn't have the junk at the start of the text: ``` RETURN VALUE Returns a pointer to the desktop display mode or NULL on failure; call SDL_GetError() for more information. ``` * joystick: Fix underflow with 0 delta timestamp Some sensors will occasionally report two identical timestamps in a row. This leads to the timestamp wrapping calculation to underflow, subtracting 0x80000000 from the timestamp whenever it happens. By adjusting the wrap test, we can just directly add zero to the timestamp, fixing the underflow. * stdinc: only use _Countof for SDL_arraysize when using a C standard > C23 * SDL_migration.cocci: add SDL_JoystickGetGUIDString -> SDL_GUIDToString. * SDL_migration.cocci: Add joystick/gamepad event state functions. * joystick: Fix conflicting rumble and LED on Sony PS4 gamepads * stdinc: make SDL_stack_free evaluate to `((void)(data))` when alloca is usable. Fixes libsdl-org#15727. * docs: Update documentation for SDL_stack_free. Reference Issue libsdl-org#15727. * Sync SDL3 wiki -> header [ci skip] * Fix web joystick vibration on Safari * examples: Added input/05-gamepad-rumble * Fix web joystick vibration (again) * Removed k_eControllerType_AndroidController and k_eControllerType_AppleController * PreseedDOSCache.cmake: Add vfork check. (djgpp actually has this symbol, believe it or not. Not sure what it could possibly do, but it says it has it!) * workflows: Stop building for Steam Runtime 3 on arm64 The experimental Steam Linux Runtime 3.0 (arm64) container is being phased out, so games that want native arm64 binaries should upgrade to Steam Linux Runtime 4.0. steamrt/tasks#1032 Signed-off-by: Simon McVittie <smcv@collabora.com> * vfork() isn't functional on DOS * Revert "vfork() isn't functional on DOS" This reverts commit 91173ab. As @icculus mentioned: I'd rather we not get into the business of making fixes by tweaking values in the Preseed files. Were there no preseed file, CMake would correctly record that the vfork function exists, so if we're really hitting the vfork() codepath on DOS, we should stop that in either CMakeLists.txt itself, or in src/process. * pipewire: Add SDL_HINT_AUDIO_DEVICE_STREAM_NAME callback earlier. Otherwise, it might cause a deadlock, if the output_callback runs in another thread while the guaranteed initial hint callback fires. One will wait for the SDL device lock, the other the pipewire thread loop lock, each already holding what the other needs. This way, the hint callback fires and we ignore it, since the stream isn't set up yet...which is good, because we're about to create the stream and set that exact same state on it directly anyhow. Now there's no chance of this deadlock happening. Reference Issue libsdl-org#15075. * examples/input/05-gamepad-rumble: add some visual feedback. * Handle java.util.ConcurrentModificationException while unregistering sensor listeners We're still seeing this frequently when unregistering PlayStation controller sensors. We don't know what else is modifying the sensor list, but if we end up getting this exception we'll retry after a short sleep. * Create a global event lock for hardware that generates events This prevents ABBA deadlocks caused by taking a hardware resource lock then delivering events at the same time another thread is taking a hardware resource lock from an event watch callback. Fixes libsdl-org#15709 * Fixed some log related thread-safety warnings * Fixed some Wayland cursor related thread-safety warnings * Fixed java.lang.NullPointerException From @AntTheAlchemist: This is an interesting one, on a Xiaomi MiTV. Caused by a camera device, full stack: android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args -> org.libsdl.app.HIDDeviceManager$1.onReceive -> handleUsbDeviceAttached -> connectHIDDeviceUSB -> getSerialNumber -> android.hardware.usb.UsbDevice.getSerialNumber -> android.hardware.usb.IUsbSerialReader$Stub.onTransact -> com.android.server.usb.UsbSerialReader.getSerial -> UsbUserPermissionManager.checkPermission -> hasPermission -> isCameraDevicePresent * Android: remove pollInputDevice() in favor of InputDeviceListener (libsdl-org#15659) * Enable extra player LED sets for PS5 Controllers * Fixed detecting PS4 controllers on Android * Added SDLControllerManager::shutdownDeviceListener() * Make initializeDeviceListener() and shutdownDeviceListener() public * Fix DirectInput POV handling for devices with extra hats * ci: ignore artifact upload errors * Add mappings for NES Switch controllers on Linux * Added SDL_CreateSurfaceUninitialized() Currently this is an internal API, but we can expose it in the future. * Added SDL_aligned_alloc_zero() * SDL_GetRenderOutputSize -> SDL_GetCurrentRenderOutputSIze SDL_GetRenderOutput size is old * Fixed bug libsdl-org#13850: SDLControllerManager, we can use isVirtual() since API > 16 * update vulkan headers from khronos. * stdlib: Add SDL_wcstoul(), SDL_wcstoll(), and SDL_wcstoull() Includes the appropriate stdlib checks and automated tests. * Sync SDL3 wiki -> header [ci skip] * Fixed ABBA deadlock on Android This fixes a deadlock when a call comes in from Java that takes the activity lock and then tries to send an event, which takes the event lock, at the same time the application thread takes the event lock and then calls SDL_RequestAndroidPermission(), which takes the activity lock. Fixes libsdl-org#15772 Fixes libsdl-org#15771 * android: fixed ANR if we lose focus at startup If we lose focus during startup, we need to unlock the activity mutex before waiting for the focus lifecycle event, otherwise it will never be delivered. Reproduced using testcontroller with a DualSense controller attached and the "Allow the app to access the USB device?" dialog popped up. * android: fixed crash adding joysticks before joysticks are initialized Fixes libsdl-org#15777 * Don't treat the IR receiver on the NVIDIA Shield TV as a joystick * dos: Fixed a comment typo * Add PID for red octane games, as they support sony detection * Fixed the Xbox 360 wireless adapter showing up as a controller * dos: Fixed some mistakes in cmake/PreseedDOSCache.cmake * Add GIP vids and pids for stage tour instruments (libsdl-org#15788) * Android: prevent removing joystick if SDL hasn't been initialized yet * Respect SDL_HINT_JOYSTICK_MFI * SDL_hidapi_xbox360.c: Fix Y axis inversion on macOS (libsdl-org#15792) Originally, macOS had opposite Y axis inversion as every other platform, likely to correct for an issue with the virtual gamepad reported by the old 360Controller driver. Wired Xbox 360 controllers using native macOS drivers were first reported to be broken in libsdl-org#11002. The inversion was removed in libsdl-org@7da728a, presumably breaking 360Controller usage, but fixing wired 360 controller using the new native support in macOS 15 and above. However, this change was reverted without explanation in libsdl-org@d7b1ba1 which added explicit support for the Steam Virtual Gamepad. Presumably, Steam on macOS reports inverted Y axes to match what SDL expected on the platform. However, this reversion broke the native macOS controller support. The incorrect inversion also breaks using off-brand 360-class gamepads via the libusb backend of HIDRAW. * Fixed the Xbox 360 Controller showing as a Steam Virtual Gamepad on macOS * Fixed a hang reading the Xbox report descriptor on macOS * audio: Split device "zombie" status into multiple stages. Otherwise, a device that is disconnected in the standard audio device thread might keep failing WaitDevice() in a tight loop, each one generating a new main thread callback. In normal situations, this is wasteful, but if the app isn't pumping the event loop quickly (or at all!), this will quickly eat up all the memory in a machine. Now we note that the device is zombified right away, and device thread iteration will use this to replace the implementation with the Zombie equivalents once it owns the device lock. The main thread callback will progress to device->zombie==2, which it uses to decide if this is a duplicate disconnect notification. Since it also owns the lock at this point, it takes the moment to set the Zombie implementation up, too. This allows things (like the WASAPI backend) to check for a non-zero zombie state immediately without having to worry if the main thread callback ran, and for the standard audio threads to also move to the Zombie implementation without waiting on that callback. (The Zombie implementation is used to make a dead device keep processing, so things that need the audio device to make progress to function will keep working, and things blindly pushing to an audio stream won't queue up endless data that isn't being consumed.) Fixes libsdl-org#15745. * Add Corsair as valid PS controller * don't fetch timestamp again * ci: run GDK on older Windows environment > > The GDK version which is set up by build-scripts/setup-gdk-desktop.py does not support Visual Studio 2026 * Add notification framework with test and dummy driver * Add D-Bus notification driver Use the core and portal notification implementations to dispatch system notifications. * Add the Windows notification driver Notifications are supported on Win10 and above. * Add the Cocoa notification driver Supported on macOS 10.14+ and iOS. * Add testnotificaiton to SDLTest.xcodeproj * Fix framework in Xcode project * Sync SDL3 wiki -> header [ci skip] * notification: Remove unused parameter * Use the Microsoft provided GameInputCreate() function (libsdl-org#15797) It does better version checking and has better compatibility. This also fixes a crash in GameInputRedist.dll when attempting to load v3 when v2 is installed on the system. In this case, a thread is created in GameInputCreate() which is not cleaned up when the object is released, and can crash later with a NULL pointer dereference. * Added support for Xbox controllers via libusb on macOS A number of third party Xbox controllers are not supported by macOS, but work with libusb and the SDL HIDAPI driver. * Added hotplug detection when using libusb Also switched to a single thread for libusb read operations instead of one thread per device * Fixed error C2440: 'function': cannot convert from 'int (__cdecl *)(libusb_context *,libusb_device *,libusb_hotplug_event,void *)' to 'libusb_hotplug_callback_fn' * Weak link the UserNotifications framework Fixes libsdl-org#15803 * Fixed warning: a function declaration without a prototype is deprecated in all versions of C * credits: Update links to Will Provost's album "The Living Proof" Amazon's store link was still "http://" instead of "https://", and since they don't have the physical CD in stock anymore (and probably won't ever again), I added a link to the album on Amazon Music, for those that want to access it. * Hide SDL_wcstoll and SDL_wcstoull for compilers not supporting long long (libsdl-org#15808) Co-authored-by: Sam Lantinga <slouken@libsdl.org> * Sync SDL3 wiki -> header [ci skip] * Use GetTempPathW() instead of GetTempPath2W() GetTempPath2() is only available on Windows 11 and Windows 10 systems with full updates. We want to be compatible back to earlier versions of Windows and the only difference between the two calls is the behavior for processes running as SYSTEM, which we don't expect for SDL applications using notifications. * EGL: Always pass the platform type when available Always pass the EGL platform type for Wayland and X11, or the driver could potentially select the wrong backend if certain envvars are misconfigured. * fix typos * Don't modify the driver signature on the web * Fix JoyCon pair type detection on the web * Fix web crash for joystick without vibration * Fix Xbox One controller detection on the web * Add an invalid #define for SDL_ThreadID() to SDL_oldnames.h (libsdl-org#15801) in SDL2 SDL_ThreadID() was a function that's now SDL_GetCurrentThreadID(), but in SDL3 SDL_ThreadID is a type, so in C++ `x = SDL_ThreadID()` is valid code (default constructor which in case of integers means 0), so that's a massive footgun. See the big comment in SDL_oldnames.h for more details. Added `#undef SDL_ThreadID` in SDL_dynapi.c because it has one of the (quite rare) cases where "SDL_ThreadID" followed by a "(" is actually correct and necessary (function pointer returning SDL_ThreadID). * Sync SDL3 wiki -> header [ci skip] * Revert "Add an invalid #define for SDL_ThreadID() to SDL_oldnames.h (libsdl-org#15801)" This reverts commit b04d026. This caused problems building sdl2-compat: https://github.com/libsdl-org/sdl2-compat/actions/runs/27378527337/job/81120423041 * hidapi: fix function pointer type mismatch in backend table The HIDAPI backend table used function pointers that didn't match the macro-renamed backend function types, which trips Clang's function sanitizer. Adding small wrappers so the backend table has the correct function types and the cast to the backend-specific device type happens inside a direct call. fixes libsdl-org#15821. * Add normalized name for Emscripten joysticks * SDL_joystick: add Austgame adapter to gamecube devices "Austgame GameCube to USB converter" is an GameCube-to-USB adapter. * cmake: Fixed some copy/paste errors in comments. * Sync SDL3 wiki -> header [ci skip] * SDL_dbus.h: define DBUS_TYPE_UNIX_FD_AS_STRING if missing. * video: Removed FIXME for something we cannot fix. Reference Issue libsdl-org#11992. * Reduce log message verbosity when shutting down KMSDRM Fixes libsdl-org#13569 * docs: Clarify the purpose of SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN. Reference Issue libsdl-org#14435. * Add "/usr/local/lib/libvulkan.dylib" as a path checked when loading Vulkan on MacOS * Add support for Virtual Pipewire Source Nodes * ci: don't trigger on documentation-only commits * Fix the "redundant redeclaration" warning for `__debugbreak` when using MinGW (libsdl-org#14264) * Removed busyloop from SDL_GPUFence on MacOS Before, MetalFence was implemented as simply a busy loop on an atomic int on metal, meaning the cpu would busy wait on the gpu to finish taking power from it and decreasing battery life. This was the only kind of cpu-gpu syncing (apart from requesting a swapchain) * Added a note about where to set global platform properties * doc: use testspriteminimal instead of testgles in android example testgles depends on SDL_test so would need ../src/test/*.c as an additonal argument. * ci: do a full cron build every day, and limit builds per push or pr (libsdl-org#15839) * cmake: use 'LINKER:SHELL:' prefix for detecting version script support * cmake: add SDL_LEAN_AND_MEAN CMake option * hidapi: do not enumerate XInput devices owned by a kernel driver via libusb on macOS * cmake: correctly report SDL_LEAN_AND_MEAN state at end of configuration * Added SDL_HINT_ENABLE_STEAM_SCREEN_KEYBOARD * Sync SDL3 wiki -> header [ci skip] * Fix discrete Joy-Con mappings on Linux * replaced mach_absolute_time() - Addresses issue libsdl-org#15115 - mach_absolute_time can be misused for fingerprinting. This is bad. - Apple docs prefer clock_gettime_nsec_np(CLOCK_UPTIME_RAW) in time.h - Since HAVE_NANOSLEEP is defined, time.h is included * Enforce the minimum version of macOS to be 10.12 - clock_gettime_nsec_np is not defined until 10.12 * updated Raw Mouse Input section in docs * cmake: add SDL_LIBUDEV_SHARED option * wayland: External windows are never hidden Needed for the GPU renderer to function properly. * wayland: Attach EGL objects to custom and external surfaces during reconfiguration They are required when using EGL with an external surface. * wikiheaders: Fix links in manpage generation. Fixes libsdl-org#15665. * dos: Don't do parameter validation in SDL_SYS_GetPrefPath. The higher level did it already. * examples: Add an example for SDL_Storage user data * examples/storage/01-user: Set up for web builds. * gles: Try to reconfigure the window instead of recreating it SDL_ReconfigureWindow will fall back to recreation if necessary. * wayland: Make external window reconfiguration more robust External window surfaces can't be destroyed and recreated, so try our best to reconfigure them when switching between GL profiles, or between GL and Vulkan. * io_uring: Annotate for ThreadSanitizer, since the ring is serializing access. This doesn't _suppress_ the warnings, it annotates our memory access pattern so ThreadSanitizer knows that threads aren't in conflict, since TSan doesn't know about io_uring's mechanisms. Fixes libsdl-org#15083. * main: If SDL_MAIN_CALLBACK_RATE="waitevent", have at least one iteration run. This way apps can at least draw an initial image to their windows before going into a deep, blocking wait for user interaction. Fixes libsdl-org#15027. * examples/input/03-gamepad-polling: Render axes in blue. It's easier to see against white than yellow was. * free capacitive sensors on joystick close Fixes: libsdl-org#15856 * Fix Apple performance frequency to match nanosecond counter The counter returns ns via clock_gettime_nsec_np, so the frequency must be SDL_NS_PER_SECOND. * gpu: Metal fence fixes * Android: hide system bars via WindowInsetsController on API 30+ The immersive-fullscreen code hid the status and navigation bars with the deprecated View.setSystemUiVisibility() flags plus FLAG_FULLSCREEN. On Android 15+ (API 35), edge-to-edge is enforced for apps targeting SDK 35+ and those flags are ignored, so the bars never hide (e.g. on a Samsung S25). Android 14 and below still honour them, which is why older devices were unaffected. Hide/show the system bars with WindowInsetsController on API 30+ (using BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE for sticky-immersive), keeping the legacy setSystemUiVisibility() path for API < 30. The minimum supported version is unchanged. (cherry picked from commit a442367) * Detect device form factor (libsdl-org#12584) * Sync SDL3 wiki -> header [ci skip] * timer: drop unused mach_base_info on Apple The Apple counter uses clock_gettime_nsec_np(CLOCK_UPTIME_RAW) and the frequency is SDL_NS_PER_SECOND, so the mach timebase is no longer used. * Android: honor suggested filename in ShowSaveFileDialog * Add basic Ubuntu Touch functions libsdl-org#12543 This adds support for: * System theme * Sandbox detection * Device form factor detection Many things aren't properly supported yet, but changes and upgrades will happen on the Ubuntu Touch side, so SDL should automatically support more Ubuntu Touch features as time goes. * Sync SDL3 wiki -> header [ci skip] * Add more information for pinch gestures on mobile (libsdl-org#15092) * Sync SDL3 wiki -> header [ci skip] * Added SDL_PIXELFORMAT_P408 and SDL_PIXELFORMAT_P416 * docs: SDL_Locale is a struct, not a function. * .wikiheaders-options: Fix Notification category. * Sync SDL3 wiki -> header [ci skip] * Sync SDL3 wiki -> header [ci skip] * Added RIDEV_NOLEGACY to improve performance in mouse relative mode (thanks @whrvt!) This change also makes it so relative mode doesn't kick in until the mouse enters the window client area. This prevents relative mode from kicking in while clicking and dragging on the title bar, etc. * gpu/vulkan renderer: Reconfigure the window on renderer creation if it has the OpenGL flag In some cases, conflicts can occur at the platform or driver level if a window initially configured for OpenGL is then used with a Vulkan-based renderer. Try to reconfigure or recreate the window in the unlikely event that it has the OpenGL flag set when initializing the Vulkan or GPU renderer to remove any platform or driver-specific OpenGL objects and properties. * Set SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER to the correct texture Fixes libsdl-org#15157 * Removed redundant check for VK_SUCCESS Fixes libsdl-org#15157 * docs: warn not to destroy an SDL_AudioStream during its callback. Fixes libsdl-org#15871. * notification: Check the icon string before duplicating Fixes libsdl-org#15877 * notification: Fix old function names in documentation * Sync SDL3 wiki -> header [ci skip] * docs: Improved SDL_CommonEvent documentation. * Fix Xcode project not building due to missing header Both `SDL3/SDL.h` and `SDL3/SDL_events.h` attempt to `#include <SDL3/SDL_notification.h>` and that header was not added to Xcode, leading to compilation failures. * iOS: Fix crash on pinch gesture Related: 6509101 After the aforementioned commit, pinching in any iOS app using SDL crashes with *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[UIPinchGestureRecognizer locationOfTouch:inView:]: index (1) beyond bounds (1).' *** First throw call stack: (0x19d31a23c 0x199de9224 0x19d37fec4 0x1a3f99bf0 0x1a3fa3c68 0x103277370 0x1a33b8b7c 0x1a33b848c 0x1a33b8238 0x1a2efc9a4 0x1a2ec1310 0x1a8ab8754 0x1a8af6c1c 0x1a8abc324 0x1a8ac79f4 0x1a2f010e8 0x1a2ee9550 0x1a2efd638 0x1a2eea040 0x1a2f0318c 0x1a2eecd48 0x1a2f062a8 0x1a2f03834 0x2b210f56c 0x19d2a5358 0x19d2a52cc 0x19d26a5a8 0x19d2341a0 0x19d23354c 0x1032bcdd8 0x1032ee2a0 0x1032ee3fc 0x1032ee360 0x102280644 0x10228042c 0x1033cd0cc 0x1032a8198 0x19a61f5dc 0x19d273960 0x19d273658 0x19d2731cc 0x19d234584 0x19d23354c 0x24299f498 0x1a2f2c244 0x1a2e97158 0x1032a5780 0x102280030 0x199e41c1c) libc++abi: terminating due to uncaught exception of type NSException As it turns out, `UIPinchGestureRecognizer` does not guarantee the presence of two touches throughout the entire duration of the pinch. When the user is releasing the touches that constitute the pinch gesture, more often than not they will release one touch before the other. When this happens, `UIPinchGestureRecognizer` *does not terminate the pinch*, but continues updating it, only with one touch remaining in the gesture. The gesture is only marked concluded when the user releases *both* touches. To prevent the crash, check that the second touch is actually available via the `numberOfTouches` property. If it is not, avoid emitting `SDL_EVENT_PINCH_UPDATE` events to prevent sending unexpected payloads downstream; there is no second touch to use anymore to calculate `(focus|span)_(x|y)`. * Added SDL_HINT_WINDOWS_RAW_MOUSE_NOLEGACY * Sync SDL3 wiki -> header [ci skip] * Fix opening pipewire device blocking indefinitely if no device If wireplumber is not running or if there is no audio device, PIPEWIRE_OpenDevice could remain stuck indefinityely on PIPEWIRE_pw_thread_loop_wait because priv->stream_init_status is never equal to PW_READY_FLAG_ALL_PREOPEN_BITS. Use PIPEWIRE_pw_thread_loop_timed_wait instead with a 2 seconds timeout and bail out with an error on timeout. A 2 seconds timeout seems plenty enough: in my observations, when there is an audio device, the wait for the device to be ready is just a few milliseconds. * cmake: Print a warning if the libdecor development library is missing libdecor is required for window decorations on Wayland when the toplevel decoration protocol is not supported, such as on GNOME and Weston. Warn if the development library can't be found, unless it was explicitly disabled. * pipewire: Don't set a specific stream name if the node name is the same. Fixes libsdl-org#15746. * time: Convert the PS2 time implementation to a dummy implementation SDL has no dummy fallback for the RTC functions, and the PS2 implementation is just an empty dummy implementation, so rename it and build it if no system-specific time functionality is found. * Android: decouple video/audio subsystems from JNI initialization Allow Android embedders to use SDL without the full video/audio Java layer by gating subsystem-specific code behind SDL_VIDEO_DISABLED and SDL_AUDIO_DISABLED preprocessor flags. This enables applications that only need joystick/gamepad support (e.g. Qt-based apps like QGroundControl) to build SDL without shipping stub Java classes for unused subsystems. Changes: - Split SDLActivity JNI method table into core (lifecycle, hints, permissions) and video (surface, input, clipboard, orientation) - Gate SDLAudioManager and SDLInputConnection JNI registration - Make checkJNIReady() subsystem-aware: no longer requires mAudioManagerClass when SDL_AUDIO_DISABLED - Group method ID resolution by subsystem in nativeSetupJNI() - Guard all video/audio function implementations and declarations - Keep display orientation accessors always available (needed by camera) - Add subsystem-selective SDL.setupJNI(int)/initialize(int) to SDL.java with backwards-compatible zero-arg overloads - Guard SDL_VIDEO_DRIVER_ANDROID and related defines in SDL_build_config_android.h * update khronos headers from mainstream. * README-migration: patched SDL_RWFromFP replacement code to compile. Reference Issue libsdl-org#15893. * keyboard: Limit text input event size for sdl2-compat * Add Void GENESIS controller support Add AndGAMER/Void Gaming USB IDs for Void GENESIS. Recognize the Void GENESIS SInput VID/PID pair and set its device name. Add DirectInput gamepad mappings for the wired and dongle DirectInput modes. * Removed unnecessary assert in WIN_SetWindowOpacity() Fixes libsdl-org#15896 * win32: Use the current cursor coordinates when processing WM_NCACTIVATE The event coordinates returned by GetMessagePos() for WM_NCACTIVATE are out of date if the cursor moved while an overlay was active, and may indicate that the cursor is still in the window when it is not. Always use the current cursor coordinates when processing this message to avoid incorrectly setting mouse focus if the cursor is no longer within the window. * gpu: make NULL object releases no-ops These functions already return immediately for NULL objects in normal builds, but it was done through CHECK_PARAM. When building with SDL_DISABLE_INVALID_PARAMS, these checks were compiled out, and NULL resources could reach backend release functions and cause segfault. Always return on NULL so API behaves consistently regardless of SDL_DISABLE_INVALID_PARAMS. * Sync SDL3 wiki -> header [ci skip] * Fixed OpenVR build * Added a workaround for a crash in NVIDIA drivers when rendering YUV with Vulkan Fixes libsdl-org#13878 * update khronos headers from mainstream. * Fixes invalid dereference in animated cursor sort `Wayland_CreateAnimatedCursor` calls `SDL_qsort` on an array of type `**SDL_Surface`, not on an array of `*SDL_Surface`. As such the void pointers in the callback need to be casted to `SDL_Surface **` not `SDL_Surface *`. This was likely not caught since it's very unlikely that reading a few bytes past the end of this array results in reading unreadable memory, so the only side effect was invalid sort results, which is a bit subtle. I caught this because I build SDL with UBSAN enabled in my debug builds, and it trapped when the multiplication of the garbage `SDL_Surface*` width and heights overflowed. I validated that the change is correct by adding logs (that have then since been removed) demonstrating that it was previously comparing garbage, and is now comparing the actual cursor surfaces. * wayland: Fix incorrect dereference when sorting icon surfaces * Issue a batch when changing render targets in the Vulkan renderer Otherwise we get rendering artifacts that look like drawing is being applied to the wrong render target * wayland: Add support for the session management protocol Add session management protocol support for saving/restoring toplevel window state across runs. * wayland: Add support for the toplevel tag protocol Uses the same ID string as the session manager protocol. * Sync SDL3 wiki -> header [ci skip] * Fixed formatting * Get the physical device properties when using an external Vulkan device Fixes `testffmpeg --sprites 100` when using the Vulkan renderer * audio: Pass the id, not the obj, to SDL_AudioDeviceDisconnected_OnMainThread. If a device has disconnected, and the app has quit the audio subsystem before the queued main thread function has run, the pointer will be bogus by the time the run occurs. So now it looks up the object from its device ID, and if the lookup returns NULL, it returns immediately and everything works out. Reference Issue libsdl-org#14856. (which might be fixed by this or not.) * Limit default search path of build-scripts/check_stdlib_usage.py * ci: bump Ubuntu runner of Intel oneAPI * ci: avoid brew creating noisy annotations * ci: disable clang-tidy on Ubuntu 22.04 Its clang-tidy is not compatible with c++17, required by Qt6 * joystick: Fix pointer sequencing in Switch Pro Controller user IMU calibration. Prevent reading potentially stale memory. No functional changes. * joystick: Apply Gyroscope Zero-Rate Offset (ZRO) subtraction to live IMU data for Switch Controllers. * dos: Use INT 0x10/AX=0x1A00 to detect VGA presence * stdinc: SDL_SetMemoryFunctions now handles NULL function pointers better. Now it does _not_ call SDL_SetError(), since that would allocate memory with the system in a weird state, and setting all four functions to NULL will restore the original memory functions, as a shortcut vs having to query SDL_GetOriginalMemoryFunctions() first. Fixes libsdl-org#15914. * Sync SDL3 wiki -> header [ci skip] * Removed helpCursor and cellCursor NSCursor selectors These don't actually exist and we don't have a better fallback. --------- Signed-off-by: Simon McVittie <smcv@collabora.com> Co-authored-by: Vittorio Romeo <mail@vittorioromeo.com> Co-authored-by: Bitwolf <65789901+Bitwolfies@users.noreply.github.com> Co-authored-by: Jason Millard <jsm174@gmail.com> Co-authored-by: Ryan C. Gordon <icculus@icculus.org> Co-authored-by: Frank Praznik <frank.praznik@gmail.com> Co-authored-by: 0xDEADCADE <69792955+0xDEADCADE@users.noreply.github.com> Co-authored-by: Ozkan Sezer <sezeroz@gmail.com> Co-authored-by: Cameron Cawley <ccawley2011@gmail.com> Co-authored-by: Carlo Bramini <carlo_bramini@users.sourceforge.net> Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com> Co-authored-by: SDL Wiki Bot <icculus-sdlwikibot@icculus.org> Co-authored-by: Sylvain Becker <sylvain.becker@gmail.com> Co-authored-by: Sam Lantinga <slouken@libsdl.org> Co-authored-by: Gabriel Wang <embedded_zhuoran@Hotmail.com> Co-authored-by: NY00123 <ny00@outlook.com> Co-authored-by: Rachel Blackman <packetdancer@gmail.com> Co-authored-by: zanadoman <domanseven@gmail.com> Co-authored-by: Evan Hemsley <2342303+thatcosmonaut@users.noreply.github.com> Co-authored-by: replicacoil <github@mail1.vbdomein.com> Co-authored-by: Vicki Pfau <vi@endrift.com> Co-authored-by: Cameron Gutman <aicommander@gmail.com> Co-authored-by: Nintorch <92302738+Nintorch@users.noreply.github.com> Co-authored-by: Simon McVittie <smcv@collabora.com> Co-authored-by: Thad House <thadhouse1@gmail.com> Co-authored-by: Zizin13 <162662805+Zizin13@users.noreply.github.com> Co-authored-by: COMRADECHOnKy <129215115+Mashedpotato98@users.noreply.github.com> Co-authored-by: Sanjay Govind <sanjay.govind9@gmail.com> Co-authored-by: QwertyChouskie <qwertychouskie@users.noreply.github.com> Co-authored-by: Alejandro Perez <github.com.rtzzj@passmail.net> Co-authored-by: expikr <77922942+expikr@users.noreply.github.com> Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com> Co-authored-by: Brenton Bostick <bostick@gmail.com> Co-authored-by: Daniel Gibson <metalcaedes@gmail.com> Co-authored-by: arnau.nau <a@rnau.me> Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com> Co-authored-by: ItchyTrack <89610751+ItchyTrack@users.noreply.github.com> Co-authored-by: Craig McLure <craig@mclure.net> Co-authored-by: Roman Fomin <rfomin@gmail.com> Co-authored-by: Alex Tselousov <alex.greylag@gmail.com> Co-authored-by: tmkk <tmkkmac@gmail.com> Co-authored-by: stahta01 <stahta01@users.noreply.github.com> Co-authored-by: Christmas-Missionary <156368675+Christmas-Missionary@users.noreply.github.com> Co-authored-by: Ethan Lee <flibitijibibo@gmail.com> Co-authored-by: Gabriel Ford <gabe@fordltc.net> Co-authored-by: Christian Semmler <mail@csemmler.com> Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com> Co-authored-by: klirktag <klirktag@protonmail.com> Co-authored-by: Semphriss <66701383+Semphriss@users.noreply.github.com> Co-authored-by: ripdog <ripdog@users.noreply.github.com> Co-authored-by: Brent Page <68482764+brentfpage@users.noreply.github.com> Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com> Co-authored-by: bubbleguuum <bubbleguuum@free.fr> Co-authored-by: Holden Ramsey <htramsey98@gmail.com> Co-authored-by: BZL <yu_gen_00@yahoo.co.jp> Co-authored-by: Andrei Sabalenka <mechakotik@gmail.com> Co-authored-by: Mason Remaley <mason@gamesbymason.com> Co-authored-by: Dimitri Alexeev <alexeev@crxmarkets.com> Co-authored-by: palxex <ex@palx.org>
Add
#define SDL_ThreadID() SDL_ThreadID_is_a_type_now_function_is_SDL_GetCurrentThreadIDto SDL_oldnames.h to make sure people don't accidentally useSDL_ThreadID()whenSDL_GetCurrentThreadID()was intended.As
SDL_ThreadIDis a type in SDL3, it can't be handled with a simple renaming macro.I added a long explanation about this in SDL_oldnames.h that people will find when running into this compiler error. It includes specific instructions what to do in different situations.
Description
In SDL2, SDL_ThreadID() was a function that's now SDL_GetCurrentThreadID(), but in SDL3 SDL_ThreadID is a type, so in C++
x = SDL_ThreadID()is valid code (default constructor which in case of integers means 0), so that's a massive footgun.While there is no good reason to use
SDL_ThreadID()in SDL3, the#definealso causes compiler errors for any code whereSDL_ThreadIDis followed by(, like function pointer definitions for functions returningSDL_ThreadID- in SDL itself it caused problems in SDL_dynapi.c, that I fixed with an#undefin that file.These cases should be pretty rare and having to work around them is weighted out (?) by catching the mistake of not renaming
SDL_ThreadID()toSDL_GetCurrentThreadID().By the way,
rename_symbols.pyso far does not do this rename[*], so it's likely that this is a common issue.I personally ran into it in dhewm3.
See the big comment in SDL_oldnames.h for more details
[*] and doing so in a way that doesn't cause breakage when running
rename_symbols.pytwice is non-trivialExisting Issue(s)
fixes #15749