Use memfd_create() to allocate the temporary SHM backing file in memory, and set the size with posix_fallocate(), which will return an error on insufficient space vs ftruncate(), which will silently succeed and allow a SIGBUS error to occur if the unbacked memory is accessed.
Additionally, make the legacy path more robust by unlinking the temp file, so it won't persist after close, and unmapping the shared memory buffer.
This adds HIDAPI support for DualShock 3 controllers on Windows, addressing the current absence of this feature in SDL. To utilize this functionality, the official Sony driver 'sixaxis.sys' must be installed. HID offers several advantages over DirectInput, including rumble support and the ability to control the LED lights that display the controller number.
This reverts commit b9ab326982.
@rainerdeyke pointed out:
"This commit is incorrect. Flipping both horizontally and vertically is not equivalent to flipping diagonally."
Since SDL_RenderFlip is an enum, SDL_FLIP_HORIZONTAL and SDL_FLIP_VERTICAL can not be OR'ed to get the "SDL_FLIP_DIAGONAL".
Render code is actually able to perform these 3 kind of "flipping" so I just added a new enum called SDL_FLIP_DIAGONAL with the OR'ed value (3) so it can be used.
- Always use internal qsort and bsearch implementation.
- add "_r" reentrant versions.
The reasons for always using the internal versions is that the C runtime
versions' callbacks are not mark STDCALL, so we would have add bridge
functions for them anyhow, The C runtime qsort_r/qsort_s have different
orders of arguments on different platforms, and most importantly: qsort()
isn't a stable sort, and isn't guaranteed to give the same ordering for
two objects marked as equal by the callback...as such, Visual Studio and
glibc can give different sort results for the same data set...in this
sense, having one piece of code shared on all platforms makes sense here,
for reliabillity.
bsearch does not have a standard _r version at all, and suffers from the
same SDLCALL concern. Since the code is simple and we would have to work
around the C runtime, it's easier to just go with the built-in function
and remove all the CMake C runtime tests.
Fixes#9159.