src/stdlib


Log

Author Commit Date CI Message
Sam Lantinga 7f42fb54 2022-07-30T16:34:40 Applied DragonFly BSD patch https://github.com/DragonFlyBSD/DeltaPorts/blob/master/ports/devel/sdl20/dragonfly/patch-src_stdlib_SDL__malloc.c
Anonymous Maarten 36dfbe5d 2022-07-28T02:06:29 stdlib: exclude mslibc functions using SDL_STATIC_LIB macro
Anonymous Maarten 5da85376 2022-07-26T21:47:52 stdlib: move all mslibc functions to SDL_mslibc.c This allows disabling LTO on them by only specifying a single file.
Dav999-v 51f75b8b 2022-07-04T16:42:46 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.
chalonverse f317d619 2022-07-01T13:59:14 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)
Sam Lantinga cbd01874 2022-06-27T16:59:50 Removed the limit on the size of the SDL error message Also added SDL_GetOriginalMemoryFunctions() Fixes https://github.com/libsdl-org/SDL/issues/5795
chalonverse 3b191580 2022-06-27T17:19:39 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
Sam Lantinga 12f14bdb 2022-06-18T07:02:38 Fixed digit count in sscanf, e.g. "%1x"
Anonymous Maarten ae7446a9 2022-06-15T20:48:54 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.
Guldoman 74bcc5a0 2022-05-05T02:23:05 stdlib: Add `SDL_utf8strnlen`
Pierre Wendling 501a4991 2022-05-05T18:44:32 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.
Cameron Cawley 0cca71a8 2022-05-18T22:12:05 Use SDLCALL for callbacks in public APIs
Ozkan Sezer ec1a0f62 2022-05-17T01:33:02 SDL_malloc.c: workaround calling convention issues for real_xxx procs.
Frank Richter 0e63b514 2022-05-07T14:52:35 Don't define memcpy(), memset() when using static VC runtime. The linker will complain about duplicated symbols otherwise (see #3662, #5156).
Sam Lantinga 8cd908e0 2022-05-06T10:51:55 Fixed building with Visual Studio 2013 Added SDL_vacopy.h since it needs to be included after Windows headers
Eddy Jansson 97774cdf 2022-04-29T14:01:03 Move in va_copy() define block from stdlib.
Ozkan Sezer e9ff4fdd 2022-04-25T23:55:50 add SDL_bsearch
Ryan C. Gordon 8df045cc 2022-03-22T15:53:40 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.
pionere 25203222 2022-02-05T11:01:25 optimize the SDL_str(case)cmp functions
pionere aec58d82 2022-02-05T10:56:43 make SDL_strcasecmp standard compliant
pionere b59ca92e 2022-02-05T10:55:09 use != '\0' comparison instead of SDL_strlen in the functions of SDL_getenv
Sam Lantinga bdafe1e0 2022-03-04T11:01:55 Fixed whitespace
Ozkan Sezer 0abc0a6f 2022-01-12T20:37:32 SDL_string.c: tidy-up gcc2 va_copy defines after previous haiku commit.
kenmays d37c9777 2022-01-12T06:48:00 haiku: updated for Haiku
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sam Lantinga ab6d0d4d 2021-12-28T15:58:15 Fixed undefined behavior in SDL_memset() (thanks andrewrk!) Fixes https://github.com/libsdl-org/SDL/issues/5147
Ozkan Sezer 840339c4 2021-12-18T14:01:02 SDL_utf8strlcpy: store trailing_bytes explicity as unsigned type.
Ozkan Sezer 507d4bcd 2021-12-18T14:01:02 SDL_utf8strlen: run bit-test explicitly on unsigned char
Ozkan Sezer a2b13e58 2021-12-02T02:28:24 SDL_iconv_string: avoid memory leak if realloc() fails.
Ozkan Sezer f14a8bfa 2021-12-01T21:33:02 fix whitespace.
Ozkan Sezer b71bfdaa 2021-12-01T20:50:40 SDL_iconv.c (encodings): mark "WCHAR_T" as ENCODING_UTF16LE for OS/2 too whcar_t is unsigned short in os/2, like windows
Misa 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.
Sam Lantinga 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
Misa 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.
Sam Lantinga 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
Sylvain e8731933 2021-11-09T13:32:28 Fixed warning: macro is not used
Sam Lantinga 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.
Ryan C. Gordon 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.
Ozkan Sezer 6407d4b0 2021-11-05T17:10:02 remove unnecessary parentheses from SDL_abs()
Kevin Colour 6cbee063 2021-11-05T01:17:29 include: Swap parameter names in atan2 functions
Ozkan Sezer 3ea35fe5 2021-10-04T21:32:00 fix SDL_atoi() fixes https://github.com/libsdl-org/SDL/issues/4811
Sam Lantinga 4ec259a7 2021-09-22T19:06:11 Fixed building on Visual Studio 2013 and older
Cameron Cawley 25a614bc 2021-09-14T20:37:35 Add SDL_asprintf and SDL_vasprintf
Sam Lantinga 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
Sam Lantinga a91ab883 2021-08-06T12:28:03 Fixed building on Windows with cmake, ninja, and clang
Jessica Clarke 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.
Ankith 559be8aa 2021-03-15T15:18:10 fix invalid out of bounds UTF8 handling
Ozkan Sezer 1957ffd2 2021-03-14T11:04:28 fixed a typo in SDL_ceilf()
Cacodemon345 dacf6cfb 2021-03-11T12:03:22 Fix compilation with iconv on FreeBSD
Ozkan Sezer a2fbc452 2021-02-15T03:02:32 replace i386 checks with __i386__
Misa 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).
Misa 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()
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Ozkan Sezer 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.
Sam Lantinga 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.
Sam Lantinga 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.
Sam Lantinga f487d63a 2020-12-03T18:16:56 Fixed crash when printing NULL wide character string
Sam Lantinga 46a84478 2020-11-24T12:43:01 Added SDL_wcscasecmp() and SDL_wcsncasecmp()
Ryan C. Gordon 55e59a4f 2020-11-16T18:48:13 crc32: Fixed include path.
Sam Lantinga 71e32f5e 2020-11-16T15:00:15 Added SDL_crc32()
Sam Lantinga 8b29aadd 2020-11-12T14:34:11 Fixed warning when building on Windows
Ryan C. Gordon 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!
Sam Lantinga 31916f11 2020-05-27T09:22:12 Fixed compiler warning building on FreeBSD
Ryan C. Gordon b0a20a15 2020-05-05T12:48:55 stdlib: Fixed compiler warnings about int vs size_t.
Sam Lantinga 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
Sam Lantinga 1d879787 2020-04-13T13:24:56 Fixed implicit linkage to ftol2() on Windows
Ryan C. Gordon d292f6bd 2020-04-10T12:17:14 stdlib: Add SDL_trunc and SDL_truncf
Sam Lantinga 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.
Sam Lantinga aa384ad0 2020-03-02T15:21:07 Fixed bug 5001 - Feature request: SDL_isupper & SDL_islower
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 65096446 2019-11-20T16:42:50 Improved XInput VID/PID detection and added SDL_wcsstr() and SDL_wcsncmp()
Ozkan Sezer eb8f14bb 2019-11-20T20:40:50 added SDL_strtokr() as a replacement for POSIX strtok_r (bug #4046.)
Ozkan Sezer fea3c8bd 2019-10-31T17:10:02 SDL_qsort.c: sync comments with version 1.15 from mainstream
Sylvain Becker b458d7a2 2019-10-30T15:13:55 Readability: remove redundant cast to the same type
Ryan C. Gordon 4001e6b3 2019-09-26T13:44:49 stdlib: Patched to compile.
Ryan C. Gordon 987aa311 2019-09-26T12:55:05 stdlib: Try to coerce VS2019 to not replace some loops with memset() calls. Fixes (?) Bugzilla #4759.
Ozkan Sezer 2ea0ec62 2019-07-31T00:07:15 better readability..
Ozkan Sezer 5f04ed5f 2019-07-31T00:06:50 SDL_iconv_string: add (char*) casts before SDL_malloc() calls.
Cameron Cawley e7b514d8 2019-01-13T23:36:31 riscos: Fix iconv warnings
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Ozkan Sezer d3fa42b8 2018-11-18T19:28:20 os/2 bits for SDL_malloc.c -- from libffi
Sam Lantinga 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.
Ozkan Sezer 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.
Ozkan Sezer 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.
Ozkan Sezer 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
Ozkan Sezer 6eeb8593 2018-09-27T01:10:50 SDL_string.c (SDL_PrintString): avoid MSVC signed/unsigned mismatch warning
Ozkan Sezer 5342ae2b 2018-09-27T01:00:50 SDL_string.c (SDL_IntPrecisionAdjust): avoid MSVC generating a memset()
Ozkan Sezer d2131ac1 2018-09-27T00:32:15 SDL_vsnprintf: implement precision for the integral value printers.
Ozkan Sezer ffc19ee2 2018-09-26T20:47:34 SDL_string.c: added comments to three SDL_FormatInfo members.
Ozkan Sezer 8743e975 2018-09-26T17:11:40 SDL_vsnprintf: when '.' is specified, take precision as 0 if it is < 0.
Ozkan Sezer 69ab8541 2018-09-26T10:40:02 SDL_vsnprintf: string printer now honors the precision. (bug #4263.)
Ozkan Sezer d0e9a364 2018-09-26T10:38:40 SDL_vsnprintf: %.* and %* now parse precision and width. (bug #4263.)
Sam Lantinga 5febdfce 2018-09-24T11:49:25 Fixed whitespace
Sam Lantinga 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
Ozkan Sezer f45f33bd 2018-08-05T10:01:01 SDL_expf: return SDL_exp() instead of SDL_uclibc_exp() for consistency.
Ethan Lee b4fe7412 2018-08-04T11:52:46 SDL_exp
Ozkan Sezer 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.
Sam Lantinga 3b4c2fdf 2018-02-13T08:13:29 Fixed bug 3947 - replace strlcpy with memcpy in SDL_strdup()
Ethan Lee 11c348b4 2018-01-17T11:53:09 SDL_log10
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018