Commit Graph

154 Commits (d71df6448b04d756555d9d9d285ba4c36b7e9f61)

Author SHA1 Message Date
Sam Lantinga dc2a682a82 Use the right kind of 0 2022-09-20 09:22:43 -07:00
Sam Lantinga 2461930601 Fixed build on RISC OS 2022-09-20 09:16:10 -07:00
Ozkan Sezer 887ae0c6eb fix build failure after commit 2a8d00634d if strtod isn't available. 2022-09-20 18:20:00 +03:00
Sam Lantinga 2a8d00634d Fixed scanning a negative number as an unsigned value
e.g. sscanf("-1", "%zu", &v)

Thanks to @sezero for the test case
2022-09-20 07:25:49 -07:00
Ozkan Sezer 3f5c46663e SDL_vsscanf: fix an uninitialized warning 2022-09-20 11:56:40 +03:00
Sam Lantinga 216e3f10bb Implemented size_t format specifiers for SDL_snprintf() and SDL_sscanf()
Fixes https://github.com/libsdl-org/SDL/issues/6264
2022-09-19 15:42:11 -07:00
Ivan Epifanov 7115ceb775 Vita: restore sceClibMemcmp 2022-09-17 10:12:46 -07:00
Sam Lantinga 67cb3874ef Fixed potential uninitialized variable usage 2022-08-12 20:51:28 -07:00
Sam Lantinga 9f30d4981e Added note about CRC algorithm compatibility 2022-08-11 14:27:08 -07:00
Sam Lantinga b4c4dd84c2 Added SDL_crc16() to be used in joystick GUIDs after 2.24.0 2022-08-11 09:53:25 -07:00
Sam Lantinga 7f42fb54ad Applied DragonFly BSD patch
https://github.com/DragonFlyBSD/DeltaPorts/blob/master/ports/devel/sdl20/dragonfly/patch-src_stdlib_SDL__malloc.c
2022-07-30 16:34:40 -07:00
Anonymous Maarten 36dfbe5d66 stdlib: exclude mslibc functions using SDL_STATIC_LIB macro 2022-07-29 15:05:19 +02:00
Anonymous Maarten 5da85376b9 stdlib: move all mslibc functions to SDL_mslibc.c
This allows disabling LTO on them by only specifying a single file.
2022-07-27 09:07:56 -07:00
Dav999-v 51f75b8b30 Fix fallback implementations of SDL_strchr and SDL_strrchr for '\0'
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.
2022-07-04 11:10:26 -04:00
chalonverse f317d619cc
Xbox GDKX support (#5869)
* Xbox GDK support (14 squashed commits)

* Added basic keyboard testing

* Update readme

* Code review fixes

* Fixed issue where controller add/removal wasn't working (since the device notification events don't work on Xbox, have to use the joystick thread to poll XInput)
2022-07-01 13:59:14 -07:00
Sam Lantinga cbd0187475 Removed the limit on the size of the SDL error message
Also added SDL_GetOriginalMemoryFunctions()

Fixes https://github.com/libsdl-org/SDL/issues/5795
2022-06-27 16:59:50 -07:00
chalonverse 3b191580c3
Windows GDK Support (#5830)
* Added GDK

* Simplfied checks in SDL_config_wingdk.h

* Added testgdk sample

* Added GDK readme

* Fixed error in merge of SDL_windows.h

* Additional GDK fixes

* OpenWatcom should not export _SDL_GDKGetTaskQueue

* Formatting fixes

* Moved initialization code into SDL_GDKRunApp
2022-06-27 10:19:39 -07:00
Sam Lantinga 12f14bdbeb Fixed digit count in sscanf, e.g. "%1x" 2022-06-18 07:02:38 -07:00
Anonymous Maarten ae7446a959 stlib: Extract SDL_memcpy and SDL_memset to its own file respectively
This is done such that we can disable LTO for these 2 functions when
building with MSVC.

This is due to a limitation of Link Time Code Generation (LTCG).
Code generation might generate a new reference to memset after linking
has started. The LTCG must make assumptions about where memset is
defined which is normally the C runtime.
2022-06-15 14:17:35 -07:00
Guldoman 74bcc5a0a3 stdlib: Add `SDL_utf8strnlen` 2022-06-09 15:18:50 -07:00
Pierre Wendling 501a499180 Add clang-format on/off comments where necessary.
Comments were added in places where INDENT-ON/OFF comments are. Places
like stdlib's asm don't need it as clang-format doesn't try to indent it.
2022-05-19 01:31:29 -07:00
Cameron Cawley 0cca71a846 Use SDLCALL for callbacks in public APIs 2022-05-18 15:01:27 -07:00
Ozkan Sezer ec1a0f62dd SDL_malloc.c: workaround calling convention issues for real_xxx procs. 2022-05-17 01:33:02 +03:00
Frank Richter 0e63b514d5 Don't define memcpy(), memset() when using static VC runtime.
The linker will complain about duplicated symbols otherwise
(see #3662, #5156).
2022-05-07 08:10:52 -07:00
Sam Lantinga 8cd908e0b9 Fixed building with Visual Studio 2013
Added SDL_vacopy.h since it needs to be included after Windows headers
2022-05-06 10:51:55 -07:00
Eddy Jansson 97774cdf72 Move in va_copy() define block from stdlib. 2022-04-29 10:39:02 -07:00
Ozkan Sezer e9ff4fdd49 add SDL_bsearch 2022-04-26 04:03:25 +03:00
Ryan C. Gordon 8df045cc7d
stdlib: just cast iconv()'s 2nd arg to void *.
This makes the compiler happy (enough) regardless of whether the C runtime
headers think this argument should be const or not.

Fixes #4966.
2022-03-22 16:14:06 -04:00
pionere 25203222f5 optimize the SDL_str(case)cmp functions 2022-03-22 12:17:50 -07:00
pionere aec58d8208 make SDL_strcasecmp standard compliant 2022-03-22 12:17:50 -07:00
pionere b59ca92e82 use != '\0' comparison instead of SDL_strlen in the functions of SDL_getenv 2022-03-22 12:17:50 -07:00
Sam Lantinga bdafe1e049 Fixed whitespace 2022-03-04 11:01:55 -08:00
Ozkan Sezer 0abc0a6f32 SDL_string.c: tidy-up gcc2 va_copy defines after previous haiku commit. 2022-01-12 20:37:32 +03:00
kenmays d37c9777b9 haiku: updated for Haiku 2022-01-12 09:32:56 -08:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sam Lantinga ab6d0d4d50 Fixed undefined behavior in SDL_memset() (thanks andrewrk!)
Fixes https://github.com/libsdl-org/SDL/issues/5147
2021-12-28 15:58:15 -08:00
Ozkan Sezer 840339c49d SDL_utf8strlcpy: store trailing_bytes explicity as unsigned type. 2021-12-18 14:01:02 +03:00
Ozkan Sezer 507d4bcd68 SDL_utf8strlen: run bit-test explicitly on unsigned char 2021-12-18 14:01:02 +03:00
Ozkan Sezer a2b13e585c SDL_iconv_string: avoid memory leak if realloc() fails. 2021-12-02 02:28:24 +03:00
Ozkan Sezer f14a8bfa4e fix whitespace. 2021-12-01 21:33:02 +03:00
Ozkan Sezer b71bfdaafb SDL_iconv.c (encodings): mark "WCHAR_T" as ENCODING_UTF16LE for OS/2 too
whcar_t is unsigned short in os/2, like windows
2021-12-01 20:50:40 +03:00
Misa 3bf7994fe2 Add and use `SDL_FALLTHROUGH` for fallthroughs
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.

So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).

Clang before Clang 10 and GCC before GCC 7 have problems with using
__attribute__ as a sole statement and warn about a "declaration not
declaring anything", so fall back to using the /* fallthrough */ comment
if we are using those older compiler versions.

Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).

All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
2021-11-12 07:26:14 +03:00
Sam Lantinga abc12a832c Revert "Add and use `SDL_FALLTHROUGH` for fallthroughs"
This reverts commit 66a08aa391.

This causes problems with older compilers:
https://github.com/libsdl-org/SDL/pull/4791#issuecomment-966630997
2021-11-11 15:58:44 -08:00
Misa 66a08aa391 Add and use `SDL_FALLTHROUGH` for fallthroughs
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.

So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).

Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).

All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
2021-11-11 07:23:25 -08:00
Sam Lantinga dc4c7d9539 Fixed infinite loop in SDL_vsnprintf() if the format string is too large for the output buffer
Fixes https://github.com/libsdl-org/SDL/issues/4940
2021-11-10 09:48:49 -08:00
Sylvain e8731933cc
Fixed warning: macro is not used 2021-11-09 13:33:25 +01:00
Sam Lantinga 5b646cd19e Build hidapi code into SDL as a new public API
This prevents conflicts with hidapi linked with applications, as well as allowing applications to make use of HIDAPI on Android and other platforms that might not normally have an implementation available.
2021-11-07 23:00:59 -08:00
Ryan C. Gordon 3acb172531 stdlib: SDL_snprintf now adds decimal places for ("%f", 0.0).
This patch was from @Markvy (thanks!).

Fixes #4795.
2021-11-07 09:34:55 -08:00
Ozkan Sezer 6407d4b0a8 remove unnecessary parentheses from SDL_abs() 2021-11-05 17:10:02 +03:00
Kevin Colour 6cbee0634e include: Swap parameter names in atan2 functions 2021-11-05 17:04:00 +03:00