|
3bf7994f
|
2021-09-27T14:38:12
|
|
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.
|
|
abc12a83
|
2021-11-11T15:58:44
|
|
Revert "Add and use `SDL_FALLTHROUGH` for fallthroughs"
This reverts commit 66a08aa3914a98667f212e79b4f0b9453203d656.
This causes problems with older compilers:
https://github.com/libsdl-org/SDL/pull/4791#issuecomment-966630997
|
|
66a08aa3
|
2021-09-27T14:38:12
|
|
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.
|
|
dc4c7d95
|
2021-11-10T09:48:49
|
|
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
|
|
e8731933
|
2021-11-09T13:32:28
|
|
Fixed warning: macro is not used
|
|
5b646cd1
|
2021-11-07T22:58:44
|
|
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.
|
|
3acb1725
|
2021-11-07T12:26:39
|
|
stdlib: SDL_snprintf now adds decimal places for ("%f", 0.0).
This patch was from @Markvy (thanks!).
Fixes #4795.
|
|
6407d4b0
|
2021-11-05T17:10:02
|
|
remove unnecessary parentheses from SDL_abs()
|
|
6cbee063
|
2021-11-05T01:17:29
|
|
include: Swap parameter names in atan2 functions
|
|
3ea35fe5
|
2021-10-04T21:32:00
|
|
fix SDL_atoi()
fixes https://github.com/libsdl-org/SDL/issues/4811
|
|
4ec259a7
|
2021-09-22T19:06:11
|
|
Fixed building on Visual Studio 2013 and older
|
|
25a614bc
|
2021-09-14T20:37:35
|
|
Add SDL_asprintf and SDL_vasprintf
|
|
79b0aae8
|
2021-09-22T11:42:10
|
|
The return value of SDL_snprintf is the number of characters that would have been written.
Fixes https://github.com/libsdl-org/SDL/issues/4762
|
|
a91ab883
|
2021-08-06T12:28:03
|
|
Fixed building on Windows with cmake, ninja, and clang
|
|
8f38ba4d
|
2021-07-29T18:02:47
|
|
Fix casts that should be using uintptr_t
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.
On most systems (anything with a flat memory hierarchy rather than using
segment-based addressing), size_t and uintptr_t are the same type.
However, on CHERI, size_t is just an integer offset, whereas uintptr_t
is still a capability as described above. Casting a pointer to size_t
will strip the metadata and validity tag, and casting from size_t to a
pointer will result in a null-derived capability whose validity tag is
not set, and thus cannot be dereferenced without faulting.
The audio and cursor casts were harmless as they intend to stuff an
integer into a pointer, but using uintptr_t is the idiomatic way to do
that and silences our compiler warnings (which our build tool makes
fatal by default as they often indicate real problems). The iconv and
egl casts were true positives as SDL_iconv_t and iconv_t are pointer
types, as is NativeDisplayType on most OSes, so this would have trapped
at run time when using the round-tripped pointers. The gles2 casts were
also harmless; the OpenGL API defines this argument to be a pointer type
(and uses the argument name "pointer"), but it in fact represents an
integer offset, so like audio and cursor the additional idiomatic cast
is needed to silence the warning.
|
|
559be8aa
|
2021-03-15T15:18:10
|
|
fix invalid out of bounds UTF8 handling
|
|
1957ffd2
|
2021-03-14T11:04:28
|
|
fixed a typo in SDL_ceilf()
|
|
dacf6cfb
|
2021-03-11T12:03:22
|
|
Fix compilation with iconv on FreeBSD
|
|
a2fbc452
|
2021-02-15T03:02:32
|
|
replace i386 checks with __i386__
|
|
3da58b47
|
2021-02-13T15:11:40
|
|
Fix errors with fallback impls of SDL_isxdigit() and SDL_ispunct()
SDL_isxdigit() should only accept A-Fa-f, not A-Za-z (it shouldn't use
SDL_isalpha()).
SDL_ispunct() shouldn't accept spaces (it should use SDL_isgraph()
instead).
|
|
dfe219ec
|
2021-02-13T11:21:19
|
|
Add all missing "is characteristic" stdlib functions
SDL has been missing a bunch of these 'isX' functions for some time,
where X is some characteristic of a given character.
This commit adds the rest of them to the SDL stdlib, so now we have:
- SDL_isalpha()
- SDL_isalnum()
- SDL_isblank()
- SDL_iscntrl()
- SDL_isxdigit()
- SDL_ispunct()
- SDL_isprint()
- SDL_isgraph()
|
|
9130f7c3
|
2021-01-02T10:25:38
|
|
Updated copyright for 2021
|
|
8a32ee24
|
2020-12-30T01:00:24
|
|
removed MSVC strtok_s use from SDL_strtokr().
no other ??_s are used elsewhere in SDL_stdinc. besides, C11 has a
strtok_s with a different signature.
|
|
93ccdee8
|
2020-12-23T13:47:49
|
|
Fixed bug 5404 - stdlib: Added SDL_round, SDL_roundf, SDL_lround and SDL_lroundf
Cameron Cawley
stdlib: Added SDL_round, SDL_roundf, SDL_lround and SDL_lroundf
The default implementation is based on the one used in the Windows RT video driver.
|
|
cb361896
|
2020-12-09T07:16:22
|
|
Fixed bug 5235 - All internal sources should include SDL_assert.h
Ryan C. Gordon
We should really stick this in SDL_internal.h or something so it's always available.
|
|
f487d63a
|
2020-12-03T18:16:56
|
|
Fixed crash when printing NULL wide character string
|
|
46a84478
|
2020-11-24T12:43:01
|
|
Added SDL_wcscasecmp() and SDL_wcsncasecmp()
|
|
55e59a4f
|
2020-11-16T18:48:13
|
|
crc32: Fixed include path.
|
|
71e32f5e
|
2020-11-16T15:00:15
|
|
Added SDL_crc32()
|
|
8b29aadd
|
2020-11-12T14:34:11
|
|
Fixed warning when building on Windows
|
|
e410b34f
|
2020-07-24T22:24:03
|
|
stdlib: Corrected implementation of SDL_wcsncmp.
It was a copy/paste of SDL_strcmp, apparently, not SDL_strncmp, so it ignored
the maxlen parameter.
Thanks to Jack Powell for pointing this out!
|
|
31916f11
|
2020-05-27T09:22:12
|
|
Fixed compiler warning building on FreeBSD
|
|
b0a20a15
|
2020-05-05T12:48:55
|
|
stdlib: Fixed compiler warnings about int vs size_t.
|
|
8b60d39c
|
2020-05-02T14:43:17
|
|
Fixed bug 5112 - CMake won't compile in VS2019
dark_sylinc
Trying to build SDL with VS2019 using CMake will encounter a linking error
More specifically:
1>SDL_string.obj : error LNK2019: unresolved external symbol memset referenced in function SDL_vsnprintf_REAL
|
|
1d879787
|
2020-04-13T13:24:56
|
|
Fixed implicit linkage to ftol2() on Windows
|
|
d292f6bd
|
2020-04-10T12:17:14
|
|
stdlib: Add SDL_trunc and SDL_truncf
|
|
342f62ca
|
2020-03-10T16:29:28
|
|
Fixed bug 5022 - SDL_iconv_string can get stuck in an infinite loop when encountering invalid characters
ciremo6483
In `SDL_iconv_string` the `while (inbytesleft > 0)` loop can end up in a state where it never terminates because the library `iconv` function called from `SDL_iconv` doesn't consume any bytes.
This happened when a `WCHAR_T` input string was being converted to `UTF-8` but contained invalid characters. It would first It would first skip a few bytes due to `case SDL_ICONV_EILSEQ` but when there were 3 bytes remaining of `inbytesleft` `iconv` just didn't consume anything more (but didn't throw an error either).
It just so happens that the Microsoft Classic IntelliMouse `product_string` contains such invalid characters (`"Microsoft? Classic IntelliMouse?"`), meaning the function would get stuck with said mouse plugged in.
A fix for this would be to check if `inbytesleft` was unchanged after an iteration and in that case either decrement the counter like when `SDL_ICONV_EILSEQ` is returned or simply break the loop.
|
|
aa384ad0
|
2020-03-02T15:21:07
|
|
Fixed bug 5001 - Feature request: SDL_isupper & SDL_islower
|
|
a8780c6a
|
2020-01-16T20:49:25
|
|
Updated copyright date for 2020
|
|
65096446
|
2019-11-20T16:42:50
|
|
Improved XInput VID/PID detection and added SDL_wcsstr() and SDL_wcsncmp()
|
|
eb8f14bb
|
2019-11-20T20:40:50
|
|
added SDL_strtokr() as a replacement for POSIX strtok_r (bug #4046.)
|
|
fea3c8bd
|
2019-10-31T17:10:02
|
|
SDL_qsort.c: sync comments with version 1.15 from mainstream
|
|
b458d7a2
|
2019-10-30T15:13:55
|
|
Readability: remove redundant cast to the same type
|
|
4001e6b3
|
2019-09-26T13:44:49
|
|
stdlib: Patched to compile.
|
|
987aa311
|
2019-09-26T12:55:05
|
|
stdlib: Try to coerce VS2019 to not replace some loops with memset() calls.
Fixes (?) Bugzilla #4759.
|
|
2ea0ec62
|
2019-07-31T00:07:15
|
|
better readability..
|
|
5f04ed5f
|
2019-07-31T00:06:50
|
|
SDL_iconv_string: add (char*) casts before SDL_malloc() calls.
|
|
e7b514d8
|
2019-01-13T23:36:31
|
|
riscos: Fix iconv warnings
|
|
5e13087b
|
2019-01-04T22:01:14
|
|
Updated copyright for 2019
|
|
d3fa42b8
|
2018-11-18T19:28:20
|
|
os/2 bits for SDL_malloc.c -- from libffi
|
|
9e8e0fb7
|
2018-09-28T20:48:18
|
|
Fixed bug 4283 - SDL's version of memset is different from libc's
janisozaur
memset's documentation reads:
* The memset() function shall copy c (converted to an unsigned char) into each of the first n bytes of the object pointed to by s. (http://pubs.opengroup.org/onlinepubs/9699919799/functions/memset.html)
* Sets the first count characters of dest to the character c. (https://msdn.microsoft.com/en-us/library/1fdeehz6.aspx)
* write a byte to a byte string (https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/memset.3.html)
The highlight here is they all mean a single _byte_, even though memset receives a parameter of type int, which can hold more data than a single byte. SDL's implementation of memset, however, does not clear any of the higher bits, causing an erroneous behaviour when passed an argument bigger than 0xff.
|
|
31596f23
|
2018-09-29T01:24:10
|
|
SDL_vsnprintf: implemented '+' flag for signed integers printing.
it is, of course, ignored for %u, %x, %o and %p.
|
|
49803c86
|
2018-09-29T00:51:24
|
|
SDL_vsnprintf: fix numerics if both zero-padding and a field are given.
it used to place zeroes between the sign and the number. (space-padding
from within SDL_PrintString() seems OK: spaces are added before sign.)
also fixed the maxlen handling if the number has a sign.
|
|
bb5516ac
|
2018-09-27T09:37:36
|
|
SDL_vsnprintf() updates for zero-padding:
- remove force-enabling of pad_zeroes for %u for compatibility
(was added in https://hg.libsdl.org/SDL/rev/701f4a25df89)
- ignore pad_zeroes for %s and %S
- ignore pad_zeroes for %d, %i and %u if a precision is given
|
|
6eeb8593
|
2018-09-27T01:10:50
|
|
SDL_string.c (SDL_PrintString): avoid MSVC signed/unsigned mismatch warning
|
|
5342ae2b
|
2018-09-27T01:00:50
|
|
SDL_string.c (SDL_IntPrecisionAdjust): avoid MSVC generating a memset()
|
|
d2131ac1
|
2018-09-27T00:32:15
|
|
SDL_vsnprintf: implement precision for the integral value printers.
|
|
ffc19ee2
|
2018-09-26T20:47:34
|
|
SDL_string.c: added comments to three SDL_FormatInfo members.
|
|
8743e975
|
2018-09-26T17:11:40
|
|
SDL_vsnprintf: when '.' is specified, take precision as 0 if it is < 0.
|
|
69ab8541
|
2018-09-26T10:40:02
|
|
SDL_vsnprintf: string printer now honors the precision. (bug #4263.)
|
|
d0e9a364
|
2018-09-26T10:38:40
|
|
SDL_vsnprintf: %.* and %* now parse precision and width. (bug #4263.)
|
|
5febdfce
|
2018-09-24T11:49:25
|
|
Fixed whitespace
|
|
d2042e1e
|
2018-08-09T16:00:17
|
|
Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms.
Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API
|
|
f45f33bd
|
2018-08-05T10:01:01
|
|
SDL_expf: return SDL_exp() instead of SDL_uclibc_exp() for consistency.
|
|
b4fe7412
|
2018-08-04T11:52:46
|
|
SDL_exp
|
|
652d59fb
|
2018-05-10T09:02:39
|
|
make sure SDL_vsnprintf() nul terminates if it is using _vsnprintf
The change makes sure that SDL_vsnprintf() nul terminates if it is
using _vsnprintf() for the job.
I made this patch for Watcom, whose _vsnprintf() doesn't guarantee
nul termination. The preprocessor check can be extended to windows
in general too, if required.
Closes bug #3769.
|
|
3b4c2fdf
|
2018-02-13T08:13:29
|
|
Fixed bug 3947 - replace strlcpy with memcpy in SDL_strdup()
|
|
11c348b4
|
2018-01-17T11:53:09
|
|
SDL_log10
|
|
e3cc5b2c
|
2018-01-03T10:03:25
|
|
Updated copyright for 2018
|
|
bcdf8b91
|
2017-11-04T17:35:03
|
|
Added SDL_fmod() and SDL_fmodf()
|
|
34502143
|
2017-11-04T15:34:14
|
|
Added float versions of SDL's math functions
|
|
758156a7
|
2017-11-04T09:37:29
|
|
Fixed bug 3917 - Android, issues with getManifestEnvironmentVariable
We're going to push the manifest environment variables from the Java side instead of continually querying for them from the native side.
|
|
8fd0c22a
|
2017-10-24T00:17:07
|
|
Added the ability to set SDL hints from AndroidManifest.xml (thanks Rachel!)
This is especially useful for things like the accelerometer hint which could be needed before application main().
|
|
fc60db86
|
2017-10-12T17:17:09
|
|
Fixed compiler warning
|
|
21cd2df6
|
2017-10-12T14:02:24
|
|
Fixed compiler warning
|
|
9c580e14
|
2017-10-12T13:44:28
|
|
Added functions to query and set the SDL memory allocation functions:
SDL_GetMemoryFunctions()
SDL_SetMemoryFunctions()
SDL_GetNumAllocations()
|
|
bef0fec1
|
2017-10-12T14:28:05
|
|
make sure that SDL_malloc(0) or SDL_calloc(0,x) doesn't return NULL.
|
|
19114b03
|
2017-09-10T12:42:38
|
|
Fixed bug 3813 - gcc7 fallthrough warnings in SDL_iconv.c and SDL_pixels.c
|
|
8ed16ea4
|
2017-09-10T10:43:04
|
|
Fixed compile warning
|
|
1b2492ed
|
2017-09-08T15:08:03
|
|
Fixed 64-bit build warning
|
|
c1fd0fbb
|
2017-09-04T22:14:57
|
|
Fixed compiler warning with mingw-w64
|
|
ae667da6
|
2017-08-29T15:52:49
|
|
Fixed a bunch of compiler warnings.
|
|
620f5342
|
2017-08-29T00:36:17
|
|
stdlib: An implementation of SDL_scalbn using ldexp() (thanks, Ozkan!).
Fixes Bugzilla #3767.
|
|
fcf83e79
|
2017-08-21T16:30:24
|
|
Fixed bug 3768 - provide a quick copysign() solution for watcom
Ozkan Sezer
The following patch provides a quick copysign solution for Watcom/x86
|
|
f1829d95
|
2017-08-13T20:37:49
|
|
Added SDL_wcscmp()
|
|
affab6ad
|
2017-08-12T00:01:24
|
|
More fixes for the SDL_scanf code
|
|
b5ea3c6d
|
2017-08-11T21:30:06
|
|
Fixed bug 3284 - minor correction for SDL_setenv on _WIN32__ platform
Coriiander
Here is a minor correction for a non-breaking mistake in SDL_setenv for __WIN32__ platform. See below for details.
FILE:
"SDL/src/stdlib/SDL_getenv.c"
FUNCTION: (__WIN32__ platform)
int SDL_setenv(const char *name, const char *value, int overwrite)
CODE:
if (!overwrite) {
char ch = 0;
const size_t len = GetEnvironmentVariableA(name, &ch, sizeof (ch));
if (len > 0) {
return 0; /* asked not to overwrite existing value. */
}
}
WHAT'S WRONG:
The 3th argument to GetEnvironmentVariable (being DWORD nSize) must be the number of characters, not the number of bytes. SDL currently passes "the size of 1 char", rather "1". While it is non-breaking (1=1 after all), it is incorrect. Furthermore there is no need to specify the 2nd and 3th arguments at all.
CORRECTION 1: (corrected argument_
if (!overwrite) {
char ch = 0;
const size_t len = GetEnvironmentVariableA(name, &ch, 1);
if (len > 0) {
return 0; /* asked not to overwrite existing value. */
}
}
CORRECTION 2: (stripped of unneeded code)
if (!overwrite) {
if (GetEnvironmentVariableA(name, NULL, 0) > 0) {
return 0; /* asked not to overwrite existing value. */
}
}
|
|
441d9ba2
|
2017-08-11T19:36:12
|
|
Fixed bug 3341 - SDL_sscanf() problem
e_pluschauskas
Why does SDL_sscanf() always returns the number of format specifiers and doesn't implements standard C library behavior?
|
|
d4086e4a
|
2017-05-29T03:01:05
|
|
stdlib: added SDL_utf8strlen().
|
|
29a047df
|
2017-05-29T00:51:38
|
|
Fixed whitespace code style.
|
|
c93bca48
|
2017-02-14T02:49:08
|
|
stdlib: Fixed crash on SDL_snprintf("%s", NULL).
Like other C runtimes, it should probably produce the string "(null)".
This bug probably only affected Windows, as most platforms use their standard
C runtime's snprintf().
|
|
5cb1ca55
|
2017-01-18T11:57:27
|
|
Fixed building with mingw32
|
|
45b774e3
|
2017-01-01T18:33:28
|
|
Updated copyright for 2017
|
|
880842cf
|
2016-12-31T16:14:51
|
|
Fixed bug 3531 - internal SDL_vsnprintf implementation access memory outside given buffer ranges
Tristan
The internal SDL_vsnprintf implementation accesses memory outside buffer. The bug existed also inside the format (%) processing, which was fixed with Bug 3441.
But there is still an invalid access, if we do not have any format inside the source string and the destination string is shorter than the format string. You can use any string for this test, as long it is longer than the buffer.
Example:
va_list argList;
char buffer[4];
SDL_vsnprintf(buffer, sizeof(buffer), "Testing", argList);
The bug is located on the 'else' branch of the format char test:
while (*fmt) {
if (*fmt == '%') {
...
} else {
if (left > 1) {
*text = *fmt;
--left;
}
++fmt;
++text;
}
}
if (left > 0) {
*text = '\0';
}
As you can see that text is always incremented, even when left is already one. When then on the last lines, *text is assigned the NULL char, the pointer is located outside bounds.
|
|
232ae688
|
2016-11-23T17:20:28
|
|
Still more compiler warning fixes for various platforms.
|
|
57d01d7d
|
2016-11-13T22:57:41
|
|
Patch from Sylvain to fix clang warnings
|
|
74e1dd4c
|
2016-11-11T13:14:00
|
|
Define _GNU_SOURCE when building SDL
|
|
79f6ba5a
|
2016-11-11T03:18:16
|
|
Fixed signed/unsigned comparison warnings in Visual Studio
|
|
40b571c9
|
2016-11-06T10:01:08
|
|
Fixed bug 3468 - _allshr in SDL_stdlib.c is not working properly
Mark Pizzolato
On Windows with Visual Studio, when building SDL as a static library using the x86 (32bit) mode, several intrinsic operations are implemented in code in SDL_stdlib.c.
One of these, _allshr() is not properly implemented and fails for some input. As a result, some operations on 64bit data elements (long long) don't always work.
I classified this bug as a blocker since things absolutely don't work when the affected code is invoked. The affected code is only invoked when SDL is compiled in x86 mode on Visual Studio when building a SDL as a static library. This build environment isn't common, and hence the bug hasn't been noticed previously.
I reopened #2537 and mentioned this problem and provided a fix. That fix is provided again here along with test code which could be added to some of the SDL test code. This test code verifies that the x86 intrinsic routines produce the same results as the native x64 instructions which these routines emulate under the Microsoft compiler. The point of the tests is to make sure that Visual Studio x86 code produces the same results as Visual Studio x64 code. Some of the arguments (or boundary conditions) may produce different results on other compiler environments, so the tests really shouldn't be run on all compilers. The test driver only actually exercised code when the compiler defines _MSC_VER, so the driver can generically be invoked without issue.
|
|
8109b137
|
2016-10-17T21:47:33
|
|
Partial fix for bug 3092 - Statically link sdl2 with /MT for msvc
Mike Linford
I'm also having trouble statically linking SDL2 on Visual Studio 2015 with /MT. My symptom is that memcpy is being defined twice.
|