SDL makes assumption that each dynamically loaded library must have
SONAME matching pattern <libname>.so.<digit>+ hence it discards any file
that has two (or more) digits after ".so". in practice however SONAME
might be in the form of ie <libname>.so.<major>.<minor>.
as a solution keep requirement for dynamically loaded files to be named
<libname>.so.* but consider all the possibilities and prefer the shortest
one.
* Fix assumption that DRI_DEVNAME begins at 0
The existing logic of the code was to count every possible entry in
KMSDRM_DRI_PATH. After this a for loop would start trying to open
filename0, filename1, filename2, etc. In recent Linux kernels (say
5.18) with simpledrm, the lowest KMSDRM_DRI_DEVNAME is often
/dev/dri/card1, rather than /dev/dri/card0, causing the code to fail
once /dev/dri/card0 has failed to open. Running:
modprobe foodrm && modprobe bardrm && rmmod foodrm
before you try to run an application with SDL KMSDRM would have also
made this fail.
* Various changes from review
- Removed newline and period from SDL error
- Explicitely compare memcmp to zero (also changed to SDL_memcmp)
- Changed memcpy to strncpy
- Less aggressive line wrapping
* Various changes from review
- strncpy to SDL_strlcpy
- removed size hardcodings for KMSDRM_DRI_PATHSIZE and
KMSDRM_DRI_DEVNAMESIZE
- made all KMSDRM_DRI defines, run-time variables to reduce bugs caused
by these defines being more build-time on Linux and more run-rime on
OpenBSD
- renamed openbsd69orgreater variable to moderndri
- altered comment from "if on OpenBSD" to add difference in 6.9
* Various changes from review
- Use max size of destination, rather than max size of source
- Less hardcodings
When building on macOS without gcc (e.g. clang) where HAVE_GCC_ATOMICS
is not defined, `SDL_AtomicTryLock` will call
`OSAtomicCompareAndSwap32Barrier` which is not yet declared.
Including OSAtomic.h on OSX resolves this error/warning:
SDL_spinlock.c:125:12: error: implicit declaration of function
'OSAtomicCompareAndSwap32Barrier' is invalid in
C99 [-Werror,-Wimplicit-function-declaration]
return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
This was reported in issue #3885 but marked Invalid and closed - possibly
because the default CMake build uses gcc instead of clang.
The documentation doesn't state that the argument is ever modified,
and no implementation does so currently.
This is a non-breaking change to guarantee as much to callers.
strchr and strrchr return a pointer to the first/last occurrence of a
character in a string, or NULL if the character is not found. According
to the C standard, the final null terminator is part of the string, and
it should thus be possible to get a pointer to the final null with
these functions. The fallback implementations of SDL_strchr and
SDL_strrchr would always return NULL if trying to find '\0', and this
commit fixes that.