SDL_stdinc.h 105 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * # CategoryStdinc
  20. *
  21. * This is a general header that includes C language support. It implements a
  22. * subset of the C runtime: these should all behave the same way as their C
  23. * runtime equivalents, but with an SDL_ prefix.
  24. */
  25. #ifndef SDL_stdinc_h_
  26. #define SDL_stdinc_h_
  27. #include <SDL3/SDL_platform_defines.h>
  28. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  29. #include <inttypes.h>
  30. #endif
  31. #include <stdarg.h>
  32. #ifndef __cplusplus
  33. #include <stdbool.h>
  34. #endif
  35. #include <stdint.h>
  36. #include <string.h>
  37. #include <wchar.h>
  38. #ifndef SDL_DISABLE_ALLOCA
  39. # ifndef alloca
  40. # ifdef HAVE_ALLOCA_H
  41. # include <alloca.h>
  42. # elif defined(SDL_PLATFORM_NETBSD)
  43. # if defined(__STRICT_ANSI__)
  44. # define SDL_DISABLE_ALLOCA
  45. # else
  46. # include <stdlib.h>
  47. # endif
  48. # elif defined(__GNUC__)
  49. # define alloca __builtin_alloca
  50. # elif defined(_MSC_VER)
  51. # include <malloc.h>
  52. # define alloca _alloca
  53. # elif defined(__WATCOMC__)
  54. # include <malloc.h>
  55. # elif defined(__BORLANDC__)
  56. # include <malloc.h>
  57. # elif defined(__DMC__)
  58. # include <stdlib.h>
  59. # elif defined(SDL_PLATFORM_AIX)
  60. # pragma alloca
  61. # elif defined(__MRC__)
  62. void *alloca(unsigned);
  63. # else
  64. void *alloca(size_t);
  65. # endif
  66. # endif
  67. #endif
  68. #ifdef SIZE_MAX
  69. # define SDL_SIZE_MAX SIZE_MAX
  70. #else
  71. # define SDL_SIZE_MAX ((size_t) -1)
  72. #endif
  73. /**
  74. * Check if the compiler supports a given builtin.
  75. * Supported by virtually all clang versions and recent gcc. Use this
  76. * instead of checking the clang version if possible.
  77. */
  78. #ifdef __has_builtin
  79. #define SDL_HAS_BUILTIN(x) __has_builtin(x)
  80. #else
  81. #define SDL_HAS_BUILTIN(x) 0
  82. #endif
  83. /**
  84. * The number of elements in an array.
  85. *
  86. * This macro looks like it double-evaluates the argument, but it does so
  87. * inside of `sizeof`, so there are no side-effects here, as expressions do
  88. * not actually run any code in these cases.
  89. *
  90. * \since This macro is available since SDL 3.0.0.
  91. */
  92. #define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
  93. /**
  94. * Macro useful for building other macros with strings in them.
  95. *
  96. * For example:
  97. *
  98. * ```c
  99. * #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(__FUNCTION__) ": " X "\n")`
  100. * ```
  101. *
  102. * \since This macro is available since SDL 3.0.0.
  103. */
  104. #define SDL_STRINGIFY_ARG(arg) #arg
  105. /**
  106. * \name Cast operators
  107. *
  108. * Use proper C++ casts when compiled as C++ to be compatible with the option
  109. * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).
  110. */
  111. /* @{ */
  112. #ifdef __cplusplus
  113. #define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
  114. #define SDL_static_cast(type, expression) static_cast<type>(expression)
  115. #define SDL_const_cast(type, expression) const_cast<type>(expression)
  116. #else
  117. #define SDL_reinterpret_cast(type, expression) ((type)(expression))
  118. #define SDL_static_cast(type, expression) ((type)(expression))
  119. #define SDL_const_cast(type, expression) ((type)(expression))
  120. #endif
  121. /* @} *//* Cast operators */
  122. /* Define a four character code as a Uint32 */
  123. #define SDL_FOURCC(A, B, C, D) \
  124. ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
  125. (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
  126. (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
  127. (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
  128. #ifdef SDL_WIKI_DOCUMENTATION_SECTION
  129. /**
  130. * Append the 64 bit integer suffix to a signed integer literal.
  131. *
  132. * This helps compilers that might believe a integer literal larger than
  133. * 0xFFFFFFFF is overflowing a 32-bit value. Use `SDL_SINT64_C(0xFFFFFFFF1)`
  134. * instead of `0xFFFFFFFF1` by itself.
  135. *
  136. * \since This macro is available since SDL 3.0.0.
  137. *
  138. * \sa SDL_UINT64_C
  139. */
  140. #define SDL_SINT64_C(c) c ## LL /* or whatever the current compiler uses. */
  141. /**
  142. * Append the 64 bit integer suffix to an unsigned integer literal.
  143. *
  144. * This helps compilers that might believe a integer literal larger than
  145. * 0xFFFFFFFF is overflowing a 32-bit value. Use `SDL_UINT64_C(0xFFFFFFFF1)`
  146. * instead of `0xFFFFFFFF1` by itself.
  147. *
  148. * \since This macro is available since SDL 3.0.0.
  149. *
  150. * \sa SDL_SINT64_C
  151. */
  152. #define SDL_UINT64_C(c) c ## ULL /* or whatever the current compiler uses. */
  153. #elif defined(INT64_C)
  154. #define SDL_SINT64_C(c) INT64_C(c)
  155. #define SDL_UINT64_C(c) UINT64_C(c)
  156. #elif defined(_MSC_VER)
  157. #define SDL_SINT64_C(c) c ## i64
  158. #define SDL_UINT64_C(c) c ## ui64
  159. #elif defined(__LP64__) || defined(_LP64)
  160. #define SDL_SINT64_C(c) c ## L
  161. #define SDL_UINT64_C(c) c ## UL
  162. #else
  163. #define SDL_SINT64_C(c) c ## LL
  164. #define SDL_UINT64_C(c) c ## ULL
  165. #endif
  166. /**
  167. * \name Basic data types
  168. */
  169. /* @{ */
  170. /**
  171. * A boolean false.
  172. *
  173. * \since This macro is available since SDL 3.0.0.
  174. *
  175. * \sa SDL_bool
  176. */
  177. #define SDL_FALSE false
  178. /**
  179. * A boolean true.
  180. *
  181. * \since This macro is available since SDL 3.0.0.
  182. *
  183. * \sa SDL_bool
  184. */
  185. #define SDL_TRUE true
  186. /**
  187. * A boolean type: true or false.
  188. *
  189. * \since This datatype is available since SDL 3.0.0.
  190. *
  191. * \sa SDL_TRUE
  192. * \sa SDL_FALSE
  193. */
  194. typedef bool SDL_bool;
  195. /**
  196. * A signed 8-bit integer type.
  197. *
  198. * \since This macro is available since SDL 3.0.0.
  199. */
  200. typedef int8_t Sint8;
  201. #define SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */
  202. #define SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */
  203. /**
  204. * An unsigned 8-bit integer type.
  205. *
  206. * \since This macro is available since SDL 3.0.0.
  207. */
  208. typedef uint8_t Uint8;
  209. #define SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */
  210. #define SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */
  211. /**
  212. * A signed 16-bit integer type.
  213. *
  214. * \since This macro is available since SDL 3.0.0.
  215. */
  216. typedef int16_t Sint16;
  217. #define SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */
  218. #define SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */
  219. /**
  220. * An unsigned 16-bit integer type.
  221. *
  222. * \since This macro is available since SDL 3.0.0.
  223. */
  224. typedef uint16_t Uint16;
  225. #define SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */
  226. #define SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */
  227. /**
  228. * A signed 32-bit integer type.
  229. *
  230. * \since This macro is available since SDL 3.0.0.
  231. */
  232. typedef int32_t Sint32;
  233. #define SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */
  234. #define SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */
  235. /**
  236. * An unsigned 32-bit integer type.
  237. *
  238. * \since This macro is available since SDL 3.0.0.
  239. */
  240. typedef uint32_t Uint32;
  241. #define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */
  242. #define SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */
  243. /**
  244. * A signed 64-bit integer type.
  245. *
  246. * \since This macro is available since SDL 3.0.0.
  247. *
  248. * \sa SDL_SINT64_C
  249. */
  250. typedef int64_t Sint64;
  251. #define SDL_MAX_SINT64 SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* 9223372036854775807 */
  252. #define SDL_MIN_SINT64 ~SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* -9223372036854775808 */
  253. /**
  254. * An unsigned 64-bit integer type.
  255. *
  256. * \since This macro is available since SDL 3.0.0.
  257. *
  258. * \sa SDL_UINT64_C
  259. */
  260. typedef uint64_t Uint64;
  261. #define SDL_MAX_UINT64 SDL_UINT64_C(0xFFFFFFFFFFFFFFFF) /* 18446744073709551615 */
  262. #define SDL_MIN_UINT64 SDL_UINT64_C(0x0000000000000000) /* 0 */
  263. /**
  264. * SDL times are signed, 64-bit integers representing nanoseconds since the
  265. * Unix epoch (Jan 1, 1970).
  266. *
  267. * They can be converted between POSIX time_t values with SDL_NS_TO_SECONDS()
  268. * and SDL_SECONDS_TO_NS(), and between Windows FILETIME values with
  269. * SDL_TimeToWindows() and SDL_TimeFromWindows().
  270. *
  271. * \since This macro is available since SDL 3.0.0.
  272. *
  273. * \sa SDL_MAX_SINT64
  274. * \sa SDL_MIN_SINT64
  275. */
  276. typedef Sint64 SDL_Time;
  277. #define SDL_MAX_TIME SDL_MAX_SINT64
  278. #define SDL_MIN_TIME SDL_MIN_SINT64
  279. /* @} *//* Basic data types */
  280. /**
  281. * \name Floating-point constants
  282. */
  283. /* @{ */
  284. #ifdef FLT_EPSILON
  285. #define SDL_FLT_EPSILON FLT_EPSILON
  286. #else
  287. /**
  288. * Epsilon constant, used for comparing floating-point numbers.
  289. *
  290. * Equals by default to platform-defined `FLT_EPSILON`, or
  291. * `1.1920928955078125e-07F` if that's not available.
  292. *
  293. * \since This macro is available since SDL 3.0.0.
  294. */
  295. #define SDL_FLT_EPSILON 1.1920928955078125e-07F /* 0x0.000002p0 */
  296. #endif
  297. /* @} *//* Floating-point constants */
  298. /* Make sure we have macros for printing width-based integers.
  299. * <stdint.h> should define these but this is not true all platforms.
  300. * (for example win32) */
  301. #ifndef SDL_PRIs64
  302. #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
  303. #define SDL_PRIs64 "I64d"
  304. #elif defined(PRIs64)
  305. #define SDL_PRIs64 PRIs64
  306. #elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE)
  307. #define SDL_PRIs64 "ld"
  308. #else
  309. #define SDL_PRIs64 "lld"
  310. #endif
  311. #endif
  312. #ifndef SDL_PRIu64
  313. #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
  314. #define SDL_PRIu64 "I64u"
  315. #elif defined(PRIu64)
  316. #define SDL_PRIu64 PRIu64
  317. #elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE)
  318. #define SDL_PRIu64 "lu"
  319. #else
  320. #define SDL_PRIu64 "llu"
  321. #endif
  322. #endif
  323. #ifndef SDL_PRIx64
  324. #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
  325. #define SDL_PRIx64 "I64x"
  326. #elif defined(PRIx64)
  327. #define SDL_PRIx64 PRIx64
  328. #elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE)
  329. #define SDL_PRIx64 "lx"
  330. #else
  331. #define SDL_PRIx64 "llx"
  332. #endif
  333. #endif
  334. #ifndef SDL_PRIX64
  335. #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
  336. #define SDL_PRIX64 "I64X"
  337. #elif defined(PRIX64)
  338. #define SDL_PRIX64 PRIX64
  339. #elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE)
  340. #define SDL_PRIX64 "lX"
  341. #else
  342. #define SDL_PRIX64 "llX"
  343. #endif
  344. #endif
  345. #ifndef SDL_PRIs32
  346. #ifdef PRId32
  347. #define SDL_PRIs32 PRId32
  348. #else
  349. #define SDL_PRIs32 "d"
  350. #endif
  351. #endif
  352. #ifndef SDL_PRIu32
  353. #ifdef PRIu32
  354. #define SDL_PRIu32 PRIu32
  355. #else
  356. #define SDL_PRIu32 "u"
  357. #endif
  358. #endif
  359. #ifndef SDL_PRIx32
  360. #ifdef PRIx32
  361. #define SDL_PRIx32 PRIx32
  362. #else
  363. #define SDL_PRIx32 "x"
  364. #endif
  365. #endif
  366. #ifndef SDL_PRIX32
  367. #ifdef PRIX32
  368. #define SDL_PRIX32 PRIX32
  369. #else
  370. #define SDL_PRIX32 "X"
  371. #endif
  372. #endif
  373. /* Annotations to help code analysis tools */
  374. #ifdef SDL_DISABLE_ANALYZE_MACROS
  375. #define SDL_IN_BYTECAP(x)
  376. #define SDL_INOUT_Z_CAP(x)
  377. #define SDL_OUT_Z_CAP(x)
  378. #define SDL_OUT_CAP(x)
  379. #define SDL_OUT_BYTECAP(x)
  380. #define SDL_OUT_Z_BYTECAP(x)
  381. #define SDL_PRINTF_FORMAT_STRING
  382. #define SDL_SCANF_FORMAT_STRING
  383. #define SDL_PRINTF_VARARG_FUNC( fmtargnumber )
  384. #define SDL_PRINTF_VARARG_FUNCV( fmtargnumber )
  385. #define SDL_SCANF_VARARG_FUNC( fmtargnumber )
  386. #define SDL_SCANF_VARARG_FUNCV( fmtargnumber )
  387. #define SDL_WPRINTF_VARARG_FUNC( fmtargnumber )
  388. #define SDL_WSCANF_VARARG_FUNC( fmtargnumber )
  389. #else
  390. #if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
  391. #include <sal.h>
  392. #define SDL_IN_BYTECAP(x) _In_bytecount_(x)
  393. #define SDL_INOUT_Z_CAP(x) _Inout_z_cap_(x)
  394. #define SDL_OUT_Z_CAP(x) _Out_z_cap_(x)
  395. #define SDL_OUT_CAP(x) _Out_cap_(x)
  396. #define SDL_OUT_BYTECAP(x) _Out_bytecap_(x)
  397. #define SDL_OUT_Z_BYTECAP(x) _Out_z_bytecap_(x)
  398. #define SDL_PRINTF_FORMAT_STRING _Printf_format_string_
  399. #define SDL_SCANF_FORMAT_STRING _Scanf_format_string_impl_
  400. #else
  401. #define SDL_IN_BYTECAP(x)
  402. #define SDL_INOUT_Z_CAP(x)
  403. #define SDL_OUT_Z_CAP(x)
  404. #define SDL_OUT_CAP(x)
  405. #define SDL_OUT_BYTECAP(x)
  406. #define SDL_OUT_Z_BYTECAP(x)
  407. #define SDL_PRINTF_FORMAT_STRING
  408. #define SDL_SCANF_FORMAT_STRING
  409. #endif
  410. #ifdef __GNUC__
  411. #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 )))
  412. #define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __printf__, fmtargnumber, 0 )))
  413. #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 )))
  414. #define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __scanf__, fmtargnumber, 0 )))
  415. #define SDL_WPRINTF_VARARG_FUNC( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, fmtargnumber+1 ))) */
  416. #define SDL_WSCANF_VARARG_FUNC( fmtargnumber ) /* __attribute__ (( format( __wscanf__, fmtargnumber, fmtargnumber+1 ))) */
  417. #else
  418. #define SDL_PRINTF_VARARG_FUNC( fmtargnumber )
  419. #define SDL_PRINTF_VARARG_FUNCV( fmtargnumber )
  420. #define SDL_SCANF_VARARG_FUNC( fmtargnumber )
  421. #define SDL_SCANF_VARARG_FUNCV( fmtargnumber )
  422. #define SDL_WPRINTF_VARARG_FUNC( fmtargnumber )
  423. #define SDL_WSCANF_VARARG_FUNC( fmtargnumber )
  424. #endif
  425. #endif /* SDL_DISABLE_ANALYZE_MACROS */
  426. #ifndef SDL_COMPILE_TIME_ASSERT
  427. #if defined(__cplusplus)
  428. /* Keep C++ case alone: Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. */
  429. #if (__cplusplus >= 201103L)
  430. #define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
  431. #endif
  432. #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
  433. #define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
  434. #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
  435. #define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
  436. #endif
  437. #endif /* !SDL_COMPILE_TIME_ASSERT */
  438. #ifndef SDL_COMPILE_TIME_ASSERT
  439. /* universal, but may trigger -Wunused-local-typedefs */
  440. #define SDL_COMPILE_TIME_ASSERT(name, x) \
  441. typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
  442. #endif
  443. /** \cond */
  444. #ifndef DOXYGEN_SHOULD_IGNORE_THIS
  445. SDL_COMPILE_TIME_ASSERT(bool, sizeof(SDL_bool) == 1);
  446. SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
  447. SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
  448. SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
  449. SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
  450. SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
  451. SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
  452. SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
  453. SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
  454. typedef struct SDL_alignment_test
  455. {
  456. Uint8 a;
  457. void *b;
  458. } SDL_alignment_test;
  459. SDL_COMPILE_TIME_ASSERT(struct_alignment, sizeof(SDL_alignment_test) == (2 * sizeof(void *)));
  460. #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  461. /** \endcond */
  462. /* Check to make sure enums are the size of ints, for structure packing.
  463. For both Watcom C/C++ and Borland C/C++ the compiler option that makes
  464. enums having the size of an int must be enabled.
  465. This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
  466. */
  467. /** \cond */
  468. #ifndef DOXYGEN_SHOULD_IGNORE_THIS
  469. #if !defined(SDL_PLATFORM_VITA) && !defined(SDL_PLATFORM_3DS)
  470. /* TODO: include/SDL_stdinc.h:390: error: size of array 'SDL_dummy_enum' is negative */
  471. typedef enum SDL_DUMMY_ENUM
  472. {
  473. DUMMY_ENUM_VALUE
  474. } SDL_DUMMY_ENUM;
  475. SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
  476. #endif
  477. #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  478. /** \endcond */
  479. #include <SDL3/SDL_begin_code.h>
  480. /* Set up for C function definitions, even when using C++ */
  481. #ifdef __cplusplus
  482. extern "C" {
  483. #endif
  484. /**
  485. * A macro to initialize an SDL interface.
  486. *
  487. * This macro will initialize an SDL interface structure and should be called
  488. * before you fill out the fields with your implementation.
  489. *
  490. * You can use it like this:
  491. *
  492. * ```c
  493. * SDL_IOStreamInterface iface;
  494. *
  495. * SDL_INIT_INTERFACE(&iface);
  496. *
  497. * // Fill in the interface function pointers with your implementation
  498. * iface.seek = ...
  499. *
  500. * stream = SDL_OpenIO(&iface, NULL);
  501. * ```
  502. *
  503. * If you are using designated initializers, you can use the size of the
  504. * interface as the version, e.g.
  505. *
  506. * ```c
  507. * SDL_IOStreamInterface iface = {
  508. * .version = sizeof(iface),
  509. * .seek = ...
  510. * };
  511. * stream = SDL_OpenIO(&iface, NULL);
  512. * ```
  513. *
  514. * \threadsafety It is safe to call this macro from any thread.
  515. *
  516. * \since This macro is available since SDL 3.0.0.
  517. *
  518. * \sa SDL_IOStreamInterface
  519. * \sa SDL_StorageInterface
  520. * \sa SDL_VirtualJoystickDesc
  521. */
  522. #define SDL_INIT_INTERFACE(iface) \
  523. do { \
  524. SDL_zerop(iface); \
  525. (iface)->version = sizeof(*(iface)); \
  526. } while (0)
  527. #ifndef SDL_DISABLE_ALLOCA
  528. #define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count))
  529. #define SDL_stack_free(data)
  530. #else
  531. #define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count))
  532. #define SDL_stack_free(data) SDL_free(data)
  533. #endif
  534. extern SDL_DECLSPEC SDL_MALLOC void * SDLCALL SDL_malloc(size_t size);
  535. extern SDL_DECLSPEC SDL_MALLOC SDL_ALLOC_SIZE2(1, 2) void * SDLCALL SDL_calloc(size_t nmemb, size_t size);
  536. extern SDL_DECLSPEC SDL_ALLOC_SIZE(2) void * SDLCALL SDL_realloc(void *mem, size_t size);
  537. extern SDL_DECLSPEC void SDLCALL SDL_free(void *mem);
  538. typedef void *(SDLCALL *SDL_malloc_func)(size_t size);
  539. typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size);
  540. typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size);
  541. typedef void (SDLCALL *SDL_free_func)(void *mem);
  542. /**
  543. * Get the original set of SDL memory functions.
  544. *
  545. * This is what SDL_malloc and friends will use by default, if there has been
  546. * no call to SDL_SetMemoryFunctions. This is not necessarily using the C
  547. * runtime's `malloc` functions behind the scenes! Different platforms and
  548. * build configurations might do any number of unexpected things.
  549. *
  550. * \param malloc_func filled with malloc function.
  551. * \param calloc_func filled with calloc function.
  552. * \param realloc_func filled with realloc function.
  553. * \param free_func filled with free function.
  554. *
  555. * \threadsafety It is safe to call this function from any thread.
  556. *
  557. * \since This function is available since SDL 3.0.0.
  558. */
  559. extern SDL_DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func,
  560. SDL_calloc_func *calloc_func,
  561. SDL_realloc_func *realloc_func,
  562. SDL_free_func *free_func);
  563. /**
  564. * Get the current set of SDL memory functions.
  565. *
  566. * \param malloc_func filled with malloc function.
  567. * \param calloc_func filled with calloc function.
  568. * \param realloc_func filled with realloc function.
  569. * \param free_func filled with free function.
  570. *
  571. * \threadsafety This does not hold a lock, so do not call this in the
  572. * unlikely event of a background thread calling
  573. * SDL_SetMemoryFunctions simultaneously.
  574. *
  575. * \since This function is available since SDL 3.0.0.
  576. *
  577. * \sa SDL_SetMemoryFunctions
  578. * \sa SDL_GetOriginalMemoryFunctions
  579. */
  580. extern SDL_DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func,
  581. SDL_calloc_func *calloc_func,
  582. SDL_realloc_func *realloc_func,
  583. SDL_free_func *free_func);
  584. /**
  585. * Replace SDL's memory allocation functions with a custom set.
  586. *
  587. * It is not safe to call this function once any allocations have been made,
  588. * as future calls to SDL_free will use the new allocator, even if they came
  589. * from an SDL_malloc made with the old one!
  590. *
  591. * If used, usually this needs to be the first call made into the SDL library,
  592. * if not the very first thing done at program startup time.
  593. *
  594. * \param malloc_func custom malloc function.
  595. * \param calloc_func custom calloc function.
  596. * \param realloc_func custom realloc function.
  597. * \param free_func custom free function.
  598. * \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError()
  599. * for more information.
  600. *
  601. * \threadsafety It is safe to call this function from any thread, but one
  602. * should not replace the memory functions once any allocations
  603. * are made!
  604. *
  605. * \since This function is available since SDL 3.0.0.
  606. *
  607. * \sa SDL_GetMemoryFunctions
  608. * \sa SDL_GetOriginalMemoryFunctions
  609. */
  610. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
  611. SDL_calloc_func calloc_func,
  612. SDL_realloc_func realloc_func,
  613. SDL_free_func free_func);
  614. /**
  615. * Allocate memory aligned to a specific value.
  616. *
  617. * If `alignment` is less than the size of `void *`, then it will be increased
  618. * to match that.
  619. *
  620. * The returned memory address will be a multiple of the alignment value, and
  621. * the amount of memory allocated will be a multiple of the alignment value.
  622. *
  623. * The memory returned by this function must be freed with SDL_aligned_free(),
  624. * and _not_ SDL_free.
  625. *
  626. * \param alignment the alignment requested.
  627. * \param size the size to allocate.
  628. * \returns a pointer to the aligned memory.
  629. *
  630. * \threadsafety It is safe to call this function from any thread.
  631. *
  632. * \since This function is available since SDL 3.0.0.
  633. *
  634. * \sa SDL_aligned_free
  635. */
  636. extern SDL_DECLSPEC SDL_MALLOC void * SDLCALL SDL_aligned_alloc(size_t alignment, size_t size);
  637. /**
  638. * Free memory allocated by SDL_aligned_alloc().
  639. *
  640. * The pointer is no longer valid after this call and cannot be dereferenced
  641. * anymore.
  642. *
  643. * \param mem a pointer previously returned by SDL_aligned_alloc.
  644. *
  645. * \threadsafety It is safe to call this function from any thread.
  646. *
  647. * \since This function is available since SDL 3.0.0.
  648. *
  649. * \sa SDL_aligned_alloc
  650. */
  651. extern SDL_DECLSPEC void SDLCALL SDL_aligned_free(void *mem);
  652. /**
  653. * Get the number of outstanding (unfreed) allocations.
  654. *
  655. * \returns the number of allocations.
  656. *
  657. * \threadsafety It is safe to call this function from any thread.
  658. *
  659. * \since This function is available since SDL 3.0.0.
  660. */
  661. extern SDL_DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
  662. extern SDL_DECLSPEC const char * SDLCALL SDL_getenv(const char *name);
  663. extern SDL_DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
  664. extern SDL_DECLSPEC int SDLCALL SDL_unsetenv(const char *name);
  665. typedef int (SDLCALL *SDL_CompareCallback)(const void *a, const void *b);
  666. extern SDL_DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, SDL_CompareCallback compare);
  667. extern SDL_DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback compare);
  668. typedef int (SDLCALL *SDL_CompareCallback_r)(void *userdata, const void *a, const void *b);
  669. extern SDL_DECLSPEC void SDLCALL SDL_qsort_r(void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata);
  670. extern SDL_DECLSPEC void * SDLCALL SDL_bsearch_r(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata);
  671. extern SDL_DECLSPEC int SDLCALL SDL_abs(int x);
  672. /* NOTE: these double-evaluate their arguments, so you should never have side effects in the parameters */
  673. #define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
  674. #define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
  675. #define SDL_clamp(x, a, b) (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x)))
  676. /**
  677. * Query if a character is alphabetic (a letter).
  678. *
  679. * **WARNING**: Regardless of system locale, this will only treat ASCII values
  680. * for English 'a-z' and 'A-Z' as true.
  681. *
  682. * \param x character value to check.
  683. * \returns non-zero if x falls within the character class, zero otherwise.
  684. *
  685. * \threadsafety It is safe to call this function from any thread.
  686. *
  687. * \since This function is available since SDL 3.0.0.
  688. */
  689. extern SDL_DECLSPEC int SDLCALL SDL_isalpha(int x);
  690. /**
  691. * Query if a character is alphabetic (a letter) or a number.
  692. *
  693. * **WARNING**: Regardless of system locale, this will only treat ASCII values
  694. * for English 'a-z', 'A-Z', and '0-9' as true.
  695. *
  696. * \param x character value to check.
  697. * \returns non-zero if x falls within the character class, zero otherwise.
  698. *
  699. * \threadsafety It is safe to call this function from any thread.
  700. *
  701. * \since This function is available since SDL 3.0.0.
  702. */
  703. extern SDL_DECLSPEC int SDLCALL SDL_isalnum(int x);
  704. /**
  705. * Report if a character is blank (a space or tab).
  706. *
  707. * **WARNING**: Regardless of system locale, this will only treat ASCII values
  708. * 0x20 (space) or 0x9 (tab) as true.
  709. *
  710. * \param x character value to check.
  711. * \returns non-zero if x falls within the character class, zero otherwise.
  712. *
  713. * \threadsafety It is safe to call this function from any thread.
  714. *
  715. * \since This function is available since SDL 3.0.0.
  716. */
  717. extern SDL_DECLSPEC int SDLCALL SDL_isblank(int x);
  718. /**
  719. * Report if a character is a control character.
  720. *
  721. * **WARNING**: Regardless of system locale, this will only treat ASCII values
  722. * 0 through 0x1F, and 0x7F, as true.
  723. *
  724. * \param x character value to check.
  725. * \returns non-zero if x falls within the character class, zero otherwise.
  726. *
  727. * \threadsafety It is safe to call this function from any thread.
  728. *
  729. * \since This function is available since SDL 3.0.0.
  730. */
  731. extern SDL_DECLSPEC int SDLCALL SDL_iscntrl(int x);
  732. /**
  733. * Report if a character is a numeric digit.
  734. *
  735. * **WARNING**: Regardless of system locale, this will only treat ASCII values
  736. * '0' (0x30) through '9' (0x39), as true.
  737. *
  738. * \param x character value to check.
  739. * \returns non-zero if x falls within the character class, zero otherwise.
  740. *
  741. * \threadsafety It is safe to call this function from any thread.
  742. *
  743. * \since This function is available since SDL 3.0.0.
  744. */
  745. extern SDL_DECLSPEC int SDLCALL SDL_isdigit(int x);
  746. /**
  747. * Report if a character is a hexadecimal digit.
  748. *
  749. * **WARNING**: Regardless of system locale, this will only treat ASCII values
  750. * 'A' through 'F', 'a' through 'f', and '0' through '9', as true.
  751. *
  752. * \param x character value to check.
  753. * \returns non-zero if x falls within the character class, zero otherwise.
  754. *
  755. * \threadsafety It is safe to call this function from any thread.
  756. *
  757. * \since This function is available since SDL 3.0.0.
  758. */
  759. extern SDL_DECLSPEC int SDLCALL SDL_isxdigit(int x);
  760. /**
  761. * Report if a character is a punctuation mark.
  762. *
  763. * **WARNING**: Regardless of system locale, this is equivalent to
  764. * `((SDL_isgraph(x)) && (!SDL_isalnum(x)))`.
  765. *
  766. * \param x character value to check.
  767. * \returns non-zero if x falls within the character class, zero otherwise.
  768. *
  769. * \threadsafety It is safe to call this function from any thread.
  770. *
  771. * \since This function is available since SDL 3.0.0.
  772. *
  773. * \sa SDL_isgraph
  774. * \sa SDL_isalnum
  775. */
  776. extern SDL_DECLSPEC int SDLCALL SDL_ispunct(int x);
  777. /**
  778. * Report if a character is whitespace.
  779. *
  780. * **WARNING**: Regardless of system locale, this will only treat the
  781. * following ASCII values as true:
  782. *
  783. * - space (0x20)
  784. * - tab (0x09)
  785. * - newline (0x0A)
  786. * - vertical tab (0x0B)
  787. * - form feed (0x0C)
  788. * - return (0x0D)
  789. *
  790. * \param x character value to check.
  791. * \returns non-zero if x falls within the character class, zero otherwise.
  792. *
  793. * \threadsafety It is safe to call this function from any thread.
  794. *
  795. * \since This function is available since SDL 3.0.0.
  796. */
  797. extern SDL_DECLSPEC int SDLCALL SDL_isspace(int x);
  798. /**
  799. * Report if a character is upper case.
  800. *
  801. * **WARNING**: Regardless of system locale, this will only treat ASCII values
  802. * 'A' through 'Z' as true.
  803. *
  804. * \param x character value to check.
  805. * \returns non-zero if x falls within the character class, zero otherwise.
  806. *
  807. * \threadsafety It is safe to call this function from any thread.
  808. *
  809. * \since This function is available since SDL 3.0.0.
  810. */
  811. extern SDL_DECLSPEC int SDLCALL SDL_isupper(int x);
  812. /**
  813. * Report if a character is lower case.
  814. *
  815. * **WARNING**: Regardless of system locale, this will only treat ASCII values
  816. * 'a' through 'z' as true.
  817. *
  818. * \param x character value to check.
  819. * \returns non-zero if x falls within the character class, zero otherwise.
  820. *
  821. * \threadsafety It is safe to call this function from any thread.
  822. *
  823. * \since This function is available since SDL 3.0.0.
  824. */
  825. extern SDL_DECLSPEC int SDLCALL SDL_islower(int x);
  826. /**
  827. * Report if a character is "printable".
  828. *
  829. * Be advised that "printable" has a definition that goes back to text
  830. * terminals from the dawn of computing, making this a sort of special case
  831. * function that is not suitable for Unicode (or most any) text management.
  832. *
  833. * **WARNING**: Regardless of system locale, this will only treat ASCII values
  834. * ' ' (0x20) through '~' (0x7E) as true.
  835. *
  836. * \param x character value to check.
  837. * \returns non-zero if x falls within the character class, zero otherwise.
  838. *
  839. * \threadsafety It is safe to call this function from any thread.
  840. *
  841. * \since This function is available since SDL 3.0.0.
  842. */
  843. extern SDL_DECLSPEC int SDLCALL SDL_isprint(int x);
  844. /**
  845. * Report if a character is any "printable" except space.
  846. *
  847. * Be advised that "printable" has a definition that goes back to text
  848. * terminals from the dawn of computing, making this a sort of special case
  849. * function that is not suitable for Unicode (or most any) text management.
  850. *
  851. * **WARNING**: Regardless of system locale, this is equivalent to
  852. * `(SDL_isprint(x)) && ((x) != ' ')`.
  853. *
  854. * \param x character value to check.
  855. * \returns non-zero if x falls within the character class, zero otherwise.
  856. *
  857. * \threadsafety It is safe to call this function from any thread.
  858. *
  859. * \since This function is available since SDL 3.0.0.
  860. *
  861. * \sa SDL_isprint
  862. */
  863. extern SDL_DECLSPEC int SDLCALL SDL_isgraph(int x);
  864. /**
  865. * Convert low-ASCII English letters to uppercase.
  866. *
  867. * **WARNING**: Regardless of system locale, this will only convert ASCII
  868. * values 'a' through 'z' to uppercase.
  869. *
  870. * This function returns the uppercase equivalent of `x`. If a character
  871. * cannot be converted, or is already uppercase, this function returns `x`.
  872. *
  873. * \param x character value to check.
  874. * \returns capitalized version of x, or x if no conversion available.
  875. *
  876. * \threadsafety It is safe to call this function from any thread.
  877. *
  878. * \since This function is available since SDL 3.0.0.
  879. */
  880. extern SDL_DECLSPEC int SDLCALL SDL_toupper(int x);
  881. /**
  882. * Convert low-ASCII English letters to lowercase.
  883. *
  884. * **WARNING**: Regardless of system locale, this will only convert ASCII
  885. * values 'A' through 'Z' to lowercase.
  886. *
  887. * This function returns the lowercase equivalent of `x`. If a character
  888. * cannot be converted, or is already lowercase, this function returns `x`.
  889. *
  890. * \param x character value to check.
  891. * \returns lowercase version of x, or x if no conversion available.
  892. *
  893. * \threadsafety It is safe to call this function from any thread.
  894. *
  895. * \since This function is available since SDL 3.0.0.
  896. */
  897. extern SDL_DECLSPEC int SDLCALL SDL_tolower(int x);
  898. extern SDL_DECLSPEC Uint16 SDLCALL SDL_crc16(Uint16 crc, const void *data, size_t len);
  899. extern SDL_DECLSPEC Uint32 SDLCALL SDL_crc32(Uint32 crc, const void *data, size_t len);
  900. extern SDL_DECLSPEC void * SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
  901. /* Take advantage of compiler optimizations for memcpy */
  902. #ifndef SDL_SLOW_MEMCPY
  903. #ifdef SDL_memcpy
  904. #undef SDL_memcpy
  905. #endif
  906. #define SDL_memcpy memcpy
  907. #endif
  908. #define SDL_copyp(dst, src) \
  909. { SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \
  910. SDL_memcpy((dst), (src), sizeof(*(src)))
  911. extern SDL_DECLSPEC void * SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
  912. /* Take advantage of compiler optimizations for memmove */
  913. #ifndef SDL_SLOW_MEMMOVE
  914. #ifdef SDL_memmove
  915. #undef SDL_memmove
  916. #endif
  917. #define SDL_memmove memmove
  918. #endif
  919. extern SDL_DECLSPEC void * SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len);
  920. extern SDL_DECLSPEC void * SDLCALL SDL_memset4(void *dst, Uint32 val, size_t dwords);
  921. /* Take advantage of compiler optimizations for memset */
  922. #ifndef SDL_SLOW_MEMSET
  923. #ifdef SDL_memset
  924. #undef SDL_memset
  925. #endif
  926. #define SDL_memset memset
  927. #endif
  928. #define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
  929. #define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
  930. #define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
  931. extern SDL_DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
  932. extern SDL_DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr);
  933. extern SDL_DECLSPEC size_t SDLCALL SDL_wcsnlen(const wchar_t *wstr, size_t maxlen);
  934. extern SDL_DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
  935. extern SDL_DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
  936. extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsdup(const wchar_t *wstr);
  937. extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle);
  938. extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsnstr(const wchar_t *haystack, const wchar_t *needle, size_t maxlen);
  939. /**
  940. * Compare two null-terminated wide strings.
  941. *
  942. * This only compares wchar_t values until it hits a null-terminating
  943. * character; it does not care if the string is well-formed UTF-16 (or UTF-32,
  944. * depending on your platform's wchar_t size), or uses valid Unicode values.
  945. *
  946. * \param str1 the first string to compare. NULL is not permitted!
  947. * \param str2 the second string to compare. NULL is not permitted!
  948. * \returns less than zero if str1 is "less than" str2, greater than zero if
  949. * str1 is "greater than" str2, and zero if the strings match
  950. * exactly.
  951. *
  952. * \threadsafety It is safe to call this function from any thread.
  953. *
  954. * \since This function is available since SDL 3.0.0.
  955. */
  956. extern SDL_DECLSPEC int SDLCALL SDL_wcscmp(const wchar_t *str1, const wchar_t *str2);
  957. /**
  958. * Compare two wide strings up to a number of wchar_t values.
  959. *
  960. * This only compares wchar_t values; it does not care if the string is
  961. * well-formed UTF-16 (or UTF-32, depending on your platform's wchar_t size),
  962. * or uses valid Unicode values.
  963. *
  964. * Note that while this function is intended to be used with UTF-16 (or
  965. * UTF-32, depending on your platform's definition of wchar_t), it is
  966. * comparing raw wchar_t values and not Unicode codepoints: `maxlen` specifies
  967. * a wchar_t limit! If the limit lands in the middle of a multi-wchar UTF-16
  968. * sequence, it will only compare a portion of the final character.
  969. *
  970. * `maxlen` specifies a maximum number of wchar_t to compare; if the strings
  971. * match to this number of wide chars (or both have matched to a
  972. * null-terminator character before this count), they will be considered
  973. * equal.
  974. *
  975. * \param str1 the first string to compare. NULL is not permitted!
  976. * \param str2 the second string to compare. NULL is not permitted!
  977. * \param maxlen the maximum number of wchar_t to compare.
  978. * \returns less than zero if str1 is "less than" str2, greater than zero if
  979. * str1 is "greater than" str2, and zero if the strings match
  980. * exactly.
  981. *
  982. * \threadsafety It is safe to call this function from any thread.
  983. *
  984. * \since This function is available since SDL 3.0.0.
  985. */
  986. extern SDL_DECLSPEC int SDLCALL SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen);
  987. /**
  988. * Compare two null-terminated wide strings, case-insensitively.
  989. *
  990. * This will work with Unicode strings, using a technique called
  991. * "case-folding" to handle the vast majority of case-sensitive human
  992. * languages regardless of system locale. It can deal with expanding values: a
  993. * German Eszett character can compare against two ASCII 's' chars and be
  994. * considered a match, for example. A notable exception: it does not handle
  995. * the Turkish 'i' character; human language is complicated!
  996. *
  997. * Depending on your platform, "wchar_t" might be 2 bytes, and expected to be
  998. * UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this
  999. * handles Unicode, it expects the string to be well-formed and not a
  1000. * null-terminated string of arbitrary bytes. Characters that are not valid
  1001. * UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT
  1002. * CHARACTER), which is to say two strings of random bits may turn out to
  1003. * match if they convert to the same amount of replacement characters.
  1004. *
  1005. * \param str1 the first string to compare. NULL is not permitted!
  1006. * \param str2 the second string to compare. NULL is not permitted!
  1007. * \returns less than zero if str1 is "less than" str2, greater than zero if
  1008. * str1 is "greater than" str2, and zero if the strings match
  1009. * exactly.
  1010. *
  1011. * \threadsafety It is safe to call this function from any thread.
  1012. *
  1013. * \since This function is available since SDL 3.0.0.
  1014. */
  1015. extern SDL_DECLSPEC int SDLCALL SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2);
  1016. /**
  1017. * Compare two wide strings, case-insensitively, up to a number of wchar_t.
  1018. *
  1019. * This will work with Unicode strings, using a technique called
  1020. * "case-folding" to handle the vast majority of case-sensitive human
  1021. * languages regardless of system locale. It can deal with expanding values: a
  1022. * German Eszett character can compare against two ASCII 's' chars and be
  1023. * considered a match, for example. A notable exception: it does not handle
  1024. * the Turkish 'i' character; human language is complicated!
  1025. *
  1026. * Depending on your platform, "wchar_t" might be 2 bytes, and expected to be
  1027. * UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this
  1028. * handles Unicode, it expects the string to be well-formed and not a
  1029. * null-terminated string of arbitrary bytes. Characters that are not valid
  1030. * UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT
  1031. * CHARACTER), which is to say two strings of random bits may turn out to
  1032. * match if they convert to the same amount of replacement characters.
  1033. *
  1034. * Note that while this function might deal with variable-sized characters,
  1035. * `maxlen` specifies a _wchar_ limit! If the limit lands in the middle of a
  1036. * multi-byte UTF-16 sequence, it may convert a portion of the final character
  1037. * to one or more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not
  1038. * to overflow a buffer.
  1039. *
  1040. * `maxlen` specifies a maximum number of wchar_t values to compare; if the
  1041. * strings match to this number of wchar_t (or both have matched to a
  1042. * null-terminator character before this number of bytes), they will be
  1043. * considered equal.
  1044. *
  1045. * \param str1 the first string to compare. NULL is not permitted!
  1046. * \param str2 the second string to compare. NULL is not permitted!
  1047. * \param maxlen the maximum number of wchar_t values to compare.
  1048. * \returns less than zero if str1 is "less than" str2, greater than zero if
  1049. * str1 is "greater than" str2, and zero if the strings match
  1050. * exactly.
  1051. *
  1052. * \threadsafety It is safe to call this function from any thread.
  1053. *
  1054. * \since This function is available since SDL 3.0.0.
  1055. */
  1056. extern SDL_DECLSPEC int SDLCALL SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen);
  1057. extern SDL_DECLSPEC long SDLCALL SDL_wcstol(const wchar_t *str, wchar_t **endp, int base);
  1058. extern SDL_DECLSPEC size_t SDLCALL SDL_strlen(const char *str);
  1059. extern SDL_DECLSPEC size_t SDLCALL SDL_strnlen(const char *str, size_t maxlen);
  1060. extern SDL_DECLSPEC size_t SDLCALL SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen);
  1061. extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes);
  1062. extern SDL_DECLSPEC size_t SDLCALL SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen);
  1063. extern SDL_DECLSPEC SDL_MALLOC char * SDLCALL SDL_strdup(const char *str);
  1064. extern SDL_DECLSPEC SDL_MALLOC char * SDLCALL SDL_strndup(const char *str, size_t maxlen);
  1065. extern SDL_DECLSPEC char * SDLCALL SDL_strrev(char *str);
  1066. /**
  1067. * Convert a string to uppercase.
  1068. *
  1069. * **WARNING**: Regardless of system locale, this will only convert ASCII
  1070. * values 'A' through 'Z' to uppercase.
  1071. *
  1072. * This function operates on a null-terminated string of bytes--even if it is
  1073. * malformed UTF-8!--and converts ASCII characters 'a' through 'z' to their
  1074. * uppercase equivalents in-place, returning the original `str` pointer.
  1075. *
  1076. * \param str the string to convert in-place. Can not be NULL.
  1077. * \returns the `str` pointer passed into this function.
  1078. *
  1079. * \threadsafety It is safe to call this function from any thread.
  1080. *
  1081. * \since This function is available since SDL 3.0.0.
  1082. *
  1083. * \sa SDL_strlwr
  1084. */
  1085. extern SDL_DECLSPEC char * SDLCALL SDL_strupr(char *str);
  1086. /**
  1087. * Convert a string to lowercase.
  1088. *
  1089. * **WARNING**: Regardless of system locale, this will only convert ASCII
  1090. * values 'A' through 'Z' to lowercase.
  1091. *
  1092. * This function operates on a null-terminated string of bytes--even if it is
  1093. * malformed UTF-8!--and converts ASCII characters 'A' through 'Z' to their
  1094. * lowercase equivalents in-place, returning the original `str` pointer.
  1095. *
  1096. * \param str the string to convert in-place. Can not be NULL.
  1097. * \returns the `str` pointer passed into this function.
  1098. *
  1099. * \threadsafety It is safe to call this function from any thread.
  1100. *
  1101. * \since This function is available since SDL 3.0.0.
  1102. *
  1103. * \sa SDL_strupr
  1104. */
  1105. extern SDL_DECLSPEC char * SDLCALL SDL_strlwr(char *str);
  1106. extern SDL_DECLSPEC char * SDLCALL SDL_strchr(const char *str, int c);
  1107. extern SDL_DECLSPEC char * SDLCALL SDL_strrchr(const char *str, int c);
  1108. extern SDL_DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
  1109. extern SDL_DECLSPEC char * SDLCALL SDL_strnstr(const char *haystack, const char *needle, size_t maxlen);
  1110. extern SDL_DECLSPEC char * SDLCALL SDL_strcasestr(const char *haystack, const char *needle);
  1111. extern SDL_DECLSPEC char * SDLCALL SDL_strtok_r(char *s1, const char *s2, char **saveptr);
  1112. extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str);
  1113. extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes);
  1114. extern SDL_DECLSPEC char * SDLCALL SDL_itoa(int value, char *str, int radix);
  1115. extern SDL_DECLSPEC char * SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
  1116. extern SDL_DECLSPEC char * SDLCALL SDL_ltoa(long value, char *str, int radix);
  1117. extern SDL_DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *str, int radix);
  1118. extern SDL_DECLSPEC char * SDLCALL SDL_lltoa(Sint64 value, char *str, int radix);
  1119. extern SDL_DECLSPEC char * SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix);
  1120. extern SDL_DECLSPEC int SDLCALL SDL_atoi(const char *str);
  1121. extern SDL_DECLSPEC double SDLCALL SDL_atof(const char *str);
  1122. extern SDL_DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base);
  1123. extern SDL_DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base);
  1124. extern SDL_DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base);
  1125. extern SDL_DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base);
  1126. extern SDL_DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp);
  1127. /**
  1128. * Compare two null-terminated UTF-8 strings.
  1129. *
  1130. * Due to the nature of UTF-8 encoding, this will work with Unicode strings,
  1131. * since effectively this function just compares bytes until it hits a
  1132. * null-terminating character. Also due to the nature of UTF-8, this can be
  1133. * used with SDL_qsort() to put strings in (roughly) alphabetical order.
  1134. *
  1135. * \param str1 the first string to compare. NULL is not permitted!
  1136. * \param str2 the second string to compare. NULL is not permitted!
  1137. * \returns less than zero if str1 is "less than" str2, greater than zero if
  1138. * str1 is "greater than" str2, and zero if the strings match
  1139. * exactly.
  1140. *
  1141. * \threadsafety It is safe to call this function from any thread.
  1142. *
  1143. * \since This function is available since SDL 3.0.0.
  1144. */
  1145. extern SDL_DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
  1146. /**
  1147. * Compare two UTF-8 strings up to a number of bytes.
  1148. *
  1149. * Due to the nature of UTF-8 encoding, this will work with Unicode strings,
  1150. * since effectively this function just compares bytes until it hits a
  1151. * null-terminating character. Also due to the nature of UTF-8, this can be
  1152. * used with SDL_qsort() to put strings in (roughly) alphabetical order.
  1153. *
  1154. * Note that while this function is intended to be used with UTF-8, it is
  1155. * doing a bytewise comparison, and `maxlen` specifies a _byte_ limit! If the
  1156. * limit lands in the middle of a multi-byte UTF-8 sequence, it will only
  1157. * compare a portion of the final character.
  1158. *
  1159. * `maxlen` specifies a maximum number of bytes to compare; if the strings
  1160. * match to this number of bytes (or both have matched to a null-terminator
  1161. * character before this number of bytes), they will be considered equal.
  1162. *
  1163. * \param str1 the first string to compare. NULL is not permitted!
  1164. * \param str2 the second string to compare. NULL is not permitted!
  1165. * \param maxlen the maximum number of _bytes_ to compare.
  1166. * \returns less than zero if str1 is "less than" str2, greater than zero if
  1167. * str1 is "greater than" str2, and zero if the strings match
  1168. * exactly.
  1169. *
  1170. * \threadsafety It is safe to call this function from any thread.
  1171. *
  1172. * \since This function is available since SDL 3.0.0.
  1173. */
  1174. extern SDL_DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
  1175. /**
  1176. * Compare two null-terminated UTF-8 strings, case-insensitively.
  1177. *
  1178. * This will work with Unicode strings, using a technique called
  1179. * "case-folding" to handle the vast majority of case-sensitive human
  1180. * languages regardless of system locale. It can deal with expanding values: a
  1181. * German Eszett character can compare against two ASCII 's' chars and be
  1182. * considered a match, for example. A notable exception: it does not handle
  1183. * the Turkish 'i' character; human language is complicated!
  1184. *
  1185. * Since this handles Unicode, it expects the string to be well-formed UTF-8
  1186. * and not a null-terminated string of arbitrary bytes. Bytes that are not
  1187. * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
  1188. * CHARACTER), which is to say two strings of random bits may turn out to
  1189. * match if they convert to the same amount of replacement characters.
  1190. *
  1191. * \param str1 the first string to compare. NULL is not permitted!
  1192. * \param str2 the second string to compare. NULL is not permitted!
  1193. * \returns less than zero if str1 is "less than" str2, greater than zero if
  1194. * str1 is "greater than" str2, and zero if the strings match
  1195. * exactly.
  1196. *
  1197. * \threadsafety It is safe to call this function from any thread.
  1198. *
  1199. * \since This function is available since SDL 3.0.0.
  1200. */
  1201. extern SDL_DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
  1202. /**
  1203. * Compare two UTF-8 strings, case-insensitively, up to a number of bytes.
  1204. *
  1205. * This will work with Unicode strings, using a technique called
  1206. * "case-folding" to handle the vast majority of case-sensitive human
  1207. * languages regardless of system locale. It can deal with expanding values: a
  1208. * German Eszett character can compare against two ASCII 's' chars and be
  1209. * considered a match, for example. A notable exception: it does not handle
  1210. * the Turkish 'i' character; human language is complicated!
  1211. *
  1212. * Since this handles Unicode, it expects the string to be well-formed UTF-8
  1213. * and not a null-terminated string of arbitrary bytes. Bytes that are not
  1214. * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
  1215. * CHARACTER), which is to say two strings of random bits may turn out to
  1216. * match if they convert to the same amount of replacement characters.
  1217. *
  1218. * Note that while this function is intended to be used with UTF-8, `maxlen`
  1219. * specifies a _byte_ limit! If the limit lands in the middle of a multi-byte
  1220. * UTF-8 sequence, it may convert a portion of the final character to one or
  1221. * more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not to overflow
  1222. * a buffer.
  1223. *
  1224. * `maxlen` specifies a maximum number of bytes to compare; if the strings
  1225. * match to this number of bytes (or both have matched to a null-terminator
  1226. * character before this number of bytes), they will be considered equal.
  1227. *
  1228. * \param str1 the first string to compare. NULL is not permitted!
  1229. * \param str2 the second string to compare. NULL is not permitted!
  1230. * \param maxlen the maximum number of bytes to compare.
  1231. * \returns less than zero if str1 is "less than" str2, greater than zero if
  1232. * str1 is "greater than" str2, and zero if the strings match
  1233. * exactly.
  1234. *
  1235. * \threadsafety It is safe to call this function from any thread.
  1236. *
  1237. * \since This function is available since SDL 3.0.0.
  1238. */
  1239. extern SDL_DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen);
  1240. /**
  1241. * Searches a string for the first occurence of any character contained in a
  1242. * breakset, and returns a pointer from the string to that character.
  1243. *
  1244. * \param str The null-terminated string to be searched.
  1245. * \param breakset A null-terminated string containing the list of characters
  1246. * to look for.
  1247. * \returns A pointer to the location, in str, of the first occurence of a
  1248. * character present in the breakset, or NULL if none is found.
  1249. *
  1250. * \threadsafety It is safe to call this function from any thread.
  1251. *
  1252. * \since This function is available since SDL 3.0.0.
  1253. */
  1254. extern SDL_DECLSPEC char * SDLCALL SDL_strpbrk(const char * SDL_RESTRICT str, const char * SDL_RESTRICT breakset);
  1255. /**
  1256. * The Unicode REPLACEMENT CHARACTER codepoint.
  1257. *
  1258. * SDL_StepUTF8() reports this codepoint when it encounters a UTF-8 string
  1259. * with encoding errors.
  1260. *
  1261. * This tends to render as something like a question mark in most places.
  1262. *
  1263. * \since This macro is available since SDL 3.0.0.
  1264. *
  1265. * \sa SDL_StepUTF8
  1266. */
  1267. #define SDL_INVALID_UNICODE_CODEPOINT 0xFFFD
  1268. /**
  1269. * Decode a UTF-8 string, one Unicode codepoint at a time.
  1270. *
  1271. * This will return the first Unicode codepoint in the UTF-8 encoded string in
  1272. * `*pstr`, and then advance `*pstr` past any consumed bytes before returning.
  1273. *
  1274. * It will not access more than `*pslen` bytes from the string. `*pslen` will
  1275. * be adjusted, as well, subtracting the number of bytes consumed.
  1276. *
  1277. * `pslen` is allowed to be NULL, in which case the string _must_ be
  1278. * NULL-terminated, as the function will blindly read until it sees the NULL
  1279. * char.
  1280. *
  1281. * if `*pslen` is zero, it assumes the end of string is reached and returns a
  1282. * zero codepoint regardless of the contents of the string buffer.
  1283. *
  1284. * If the resulting codepoint is zero (a NULL terminator), or `*pslen` is
  1285. * zero, it will not advance `*pstr` or `*pslen` at all.
  1286. *
  1287. * Generally this function is called in a loop until it returns zero,
  1288. * adjusting its parameters each iteration.
  1289. *
  1290. * If an invalid UTF-8 sequence is encountered, this function returns
  1291. * SDL_INVALID_UNICODE_CODEPOINT and advances the string/length by one byte
  1292. * (which is to say, a multibyte sequence might produce several
  1293. * SDL_INVALID_UNICODE_CODEPOINT returns before it syncs to the next valid
  1294. * UTF-8 sequence).
  1295. *
  1296. * Several things can generate invalid UTF-8 sequences, including overlong
  1297. * encodings, the use of UTF-16 surrogate values, and truncated data. Please
  1298. * refer to
  1299. * [RFC3629](https://www.ietf.org/rfc/rfc3629.txt)
  1300. * for details.
  1301. *
  1302. * \param pstr a pointer to a UTF-8 string pointer to be read and adjusted.
  1303. * \param pslen a pointer to the number of bytes in the string, to be read and
  1304. * adjusted. NULL is allowed.
  1305. * \returns the first Unicode codepoint in the string.
  1306. *
  1307. * \threadsafety It is safe to call this function from any thread.
  1308. *
  1309. * \since This function is available since SDL 3.0.0.
  1310. */
  1311. extern SDL_DECLSPEC Uint32 SDLCALL SDL_StepUTF8(const char **pstr, size_t *pslen);
  1312. /**
  1313. * Convert a single Unicode codepoint to UTF-8.
  1314. *
  1315. * The buffer pointed to by `dst` must be at least 4 bytes long, as this
  1316. * function may generate between 1 and 4 bytes of output.
  1317. *
  1318. * This function returns the first byte _after_ the newly-written UTF-8
  1319. * sequence, which is useful for encoding multiple codepoints in a loop, or
  1320. * knowing where to write a NULL-terminator character to end the string (in
  1321. * either case, plan to have a buffer of _more_ than 4 bytes!).
  1322. *
  1323. * If `codepoint` is an invalid value (outside the Unicode range, or a UTF-16
  1324. * surrogate value, etc), this will use U+FFFD (REPLACEMENT CHARACTER) for the
  1325. * codepoint instead, and not set an error.
  1326. *
  1327. * If `dst` is NULL, this returns NULL immediately without writing to the
  1328. * pointer and without setting an error.
  1329. *
  1330. * \param codepoint a Unicode codepoint to convert to UTF-8.
  1331. * \param dst the location to write the encoded UTF-8. Must point to at least
  1332. * 4 bytes!
  1333. * \returns the first byte past the newly-written UTF-8 sequence.
  1334. *
  1335. * \threadsafety It is safe to call this function from any thread.
  1336. *
  1337. * \since This function is available since SDL 3.0.0.
  1338. */
  1339. extern SDL_DECLSPEC char * SDLCALL SDL_UCS4ToUTF8(Uint32 codepoint, char *dst);
  1340. extern SDL_DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2);
  1341. extern SDL_DECLSPEC int SDLCALL SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2);
  1342. extern SDL_DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3);
  1343. extern SDL_DECLSPEC int SDLCALL SDL_swprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, ... ) SDL_WPRINTF_VARARG_FUNC(3);
  1344. extern SDL_DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3);
  1345. extern SDL_DECLSPEC int SDLCALL SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, const wchar_t *fmt, va_list ap);
  1346. extern SDL_DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
  1347. extern SDL_DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2);
  1348. /**
  1349. * Seeds the pseudo-random number generator.
  1350. *
  1351. * Reusing the seed number will cause SDL_rand_*() to repeat the same stream
  1352. * of 'random' numbers.
  1353. *
  1354. * \param seed the value to use as a random number seed, or 0 to use
  1355. * SDL_GetPerformanceCounter().
  1356. *
  1357. * \threadsafety This should be called on the same thread that calls
  1358. * SDL_rand*()
  1359. *
  1360. * \since This function is available since SDL 3.0.0.
  1361. *
  1362. * \sa SDL_rand
  1363. * \sa SDL_rand_bits
  1364. * \sa SDL_randf
  1365. */
  1366. extern SDL_DECLSPEC void SDLCALL SDL_srand(Uint64 seed);
  1367. /**
  1368. * Generate a pseudo-random number less than n for positive n
  1369. *
  1370. * The method used is faster and of better quality than `rand() % n`. Odds are
  1371. * roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and
  1372. * much worse as n gets bigger.
  1373. *
  1374. * Example: to simulate a d6 use `SDL_rand(6) + 1` The +1 converts 0..5 to
  1375. * 1..6
  1376. *
  1377. * If you want to generate a pseudo-random number in the full range of Sint32,
  1378. * you should use: (Sint32)SDL_rand_bits()
  1379. *
  1380. * If you want reproducible output, be sure to initialize with SDL_srand()
  1381. * first.
  1382. *
  1383. * There are no guarantees as to the quality of the random sequence produced,
  1384. * and this should not be used for security (cryptography, passwords) or where
  1385. * money is on the line (loot-boxes, casinos). There are many random number
  1386. * libraries available with different characteristics and you should pick one
  1387. * of those to meet any serious needs.
  1388. *
  1389. * \param n the number of possible outcomes. n must be positive.
  1390. * \returns a random value in the range of [0 .. n-1].
  1391. *
  1392. * \threadsafety All calls should be made from a single thread
  1393. *
  1394. * \since This function is available since SDL 3.0.0.
  1395. *
  1396. * \sa SDL_srand
  1397. * \sa SDL_randf
  1398. */
  1399. extern SDL_DECLSPEC Sint32 SDLCALL SDL_rand(Sint32 n);
  1400. /**
  1401. * Generate a uniform pseudo-random floating point number less than 1.0
  1402. *
  1403. * If you want reproducible output, be sure to initialize with SDL_srand()
  1404. * first.
  1405. *
  1406. * There are no guarantees as to the quality of the random sequence produced,
  1407. * and this should not be used for security (cryptography, passwords) or where
  1408. * money is on the line (loot-boxes, casinos). There are many random number
  1409. * libraries available with different characteristics and you should pick one
  1410. * of those to meet any serious needs.
  1411. *
  1412. * \returns a random value in the range of [0.0, 1.0).
  1413. *
  1414. * \threadsafety All calls should be made from a single thread
  1415. *
  1416. * \since This function is available since SDL 3.0.0.
  1417. *
  1418. * \sa SDL_srand
  1419. * \sa SDL_rand
  1420. */
  1421. extern SDL_DECLSPEC float SDLCALL SDL_randf(void);
  1422. /**
  1423. * Generate 32 pseudo-random bits.
  1424. *
  1425. * You likely want to use SDL_rand() to get a psuedo-random number instead.
  1426. *
  1427. * There are no guarantees as to the quality of the random sequence produced,
  1428. * and this should not be used for security (cryptography, passwords) or where
  1429. * money is on the line (loot-boxes, casinos). There are many random number
  1430. * libraries available with different characteristics and you should pick one
  1431. * of those to meet any serious needs.
  1432. *
  1433. * \returns a random value in the range of [0-SDL_MAX_UINT32].
  1434. *
  1435. * \threadsafety All calls should be made from a single thread
  1436. *
  1437. * \since This function is available since SDL 3.0.0.
  1438. *
  1439. * \sa SDL_rand
  1440. * \sa SDL_randf
  1441. * \sa SDL_srand
  1442. */
  1443. extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits(void);
  1444. /**
  1445. * Generate a pseudo-random number less than n for positive n
  1446. *
  1447. * The method used is faster and of better quality than `rand() % n`. Odds are
  1448. * roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and
  1449. * much worse as n gets bigger.
  1450. *
  1451. * Example: to simulate a d6 use `SDL_rand_r(state, 6) + 1` The +1 converts
  1452. * 0..5 to 1..6
  1453. *
  1454. * If you want to generate a pseudo-random number in the full range of Sint32,
  1455. * you should use: (Sint32)SDL_rand_bits_r(state)
  1456. *
  1457. * There are no guarantees as to the quality of the random sequence produced,
  1458. * and this should not be used for security (cryptography, passwords) or where
  1459. * money is on the line (loot-boxes, casinos). There are many random number
  1460. * libraries available with different characteristics and you should pick one
  1461. * of those to meet any serious needs.
  1462. *
  1463. * \param state a pointer to the current random number state, this may not be
  1464. * NULL.
  1465. * \param n the number of possible outcomes. n must be positive.
  1466. * \returns a random value in the range of [0 .. n-1].
  1467. *
  1468. * \threadsafety This function is thread-safe, as long as the state pointer
  1469. * isn't shared between threads.
  1470. *
  1471. * \since This function is available since SDL 3.0.0.
  1472. *
  1473. * \sa SDL_rand
  1474. * \sa SDL_rand_bits_r
  1475. * \sa SDL_randf_r
  1476. */
  1477. extern SDL_DECLSPEC Sint32 SDLCALL SDL_rand_r(Uint64 *state, Sint32 n);
  1478. /**
  1479. * Generate a uniform pseudo-random floating point number less than 1.0
  1480. *
  1481. * If you want reproducible output, be sure to initialize with SDL_srand()
  1482. * first.
  1483. *
  1484. * There are no guarantees as to the quality of the random sequence produced,
  1485. * and this should not be used for security (cryptography, passwords) or where
  1486. * money is on the line (loot-boxes, casinos). There are many random number
  1487. * libraries available with different characteristics and you should pick one
  1488. * of those to meet any serious needs.
  1489. *
  1490. * \param state a pointer to the current random number state, this may not be
  1491. * NULL.
  1492. * \returns a random value in the range of [0.0, 1.0).
  1493. *
  1494. * \threadsafety This function is thread-safe, as long as the state pointer
  1495. * isn't shared between threads.
  1496. *
  1497. * \since This function is available since SDL 3.0.0.
  1498. *
  1499. * \sa SDL_rand_bits_r
  1500. * \sa SDL_rand_r
  1501. * \sa SDL_randf
  1502. */
  1503. extern SDL_DECLSPEC float SDLCALL SDL_randf_r(Uint64 *state);
  1504. /**
  1505. * Generate 32 pseudo-random bits.
  1506. *
  1507. * You likely want to use SDL_rand_r() to get a psuedo-random number instead.
  1508. *
  1509. * There are no guarantees as to the quality of the random sequence produced,
  1510. * and this should not be used for security (cryptography, passwords) or where
  1511. * money is on the line (loot-boxes, casinos). There are many random number
  1512. * libraries available with different characteristics and you should pick one
  1513. * of those to meet any serious needs.
  1514. *
  1515. * \param state a pointer to the current random number state, this may not be
  1516. * NULL.
  1517. * \returns a random value in the range of [0-SDL_MAX_UINT32].
  1518. *
  1519. * \threadsafety This function is thread-safe, as long as the state pointer
  1520. * isn't shared between threads.
  1521. *
  1522. * \since This function is available since SDL 3.0.0.
  1523. *
  1524. * \sa SDL_rand_r
  1525. * \sa SDL_randf_r
  1526. */
  1527. extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits_r(Uint64 *state);
  1528. #ifndef SDL_PI_D
  1529. #define SDL_PI_D 3.141592653589793238462643383279502884 /**< pi (double) */
  1530. #endif
  1531. #ifndef SDL_PI_F
  1532. #define SDL_PI_F 3.141592653589793238462643383279502884F /**< pi (float) */
  1533. #endif
  1534. /**
  1535. * Compute the arc cosine of `x`.
  1536. *
  1537. * The definition of `y = acos(x)` is `x = cos(y)`.
  1538. *
  1539. * Domain: `-1 <= x <= 1`
  1540. *
  1541. * Range: `0 <= y <= Pi`
  1542. *
  1543. * This function operates on double-precision floating point values, use
  1544. * SDL_acosf for single-precision floats.
  1545. *
  1546. * This function may use a different approximation across different versions,
  1547. * platforms and configurations. i.e, it can return a different value given
  1548. * the same input on different machines or operating systems, or if SDL is
  1549. * updated.
  1550. *
  1551. * \param x floating point value.
  1552. * \returns arc cosine of `x`, in radians.
  1553. *
  1554. * \threadsafety It is safe to call this function from any thread.
  1555. *
  1556. * \since This function is available since SDL 3.0.0.
  1557. *
  1558. * \sa SDL_acosf
  1559. * \sa SDL_asin
  1560. * \sa SDL_cos
  1561. */
  1562. extern SDL_DECLSPEC double SDLCALL SDL_acos(double x);
  1563. /**
  1564. * Compute the arc cosine of `x`.
  1565. *
  1566. * The definition of `y = acos(x)` is `x = cos(y)`.
  1567. *
  1568. * Domain: `-1 <= x <= 1`
  1569. *
  1570. * Range: `0 <= y <= Pi`
  1571. *
  1572. * This function operates on single-precision floating point values, use
  1573. * SDL_acos for double-precision floats.
  1574. *
  1575. * This function may use a different approximation across different versions,
  1576. * platforms and configurations. i.e, it can return a different value given
  1577. * the same input on different machines or operating systems, or if SDL is
  1578. * updated.
  1579. *
  1580. * \param x floating point value.
  1581. * \returns arc cosine of `x`, in radians.
  1582. *
  1583. * \threadsafety It is safe to call this function from any thread.
  1584. *
  1585. * \since This function is available since SDL 3.0.0.
  1586. *
  1587. * \sa SDL_acos
  1588. * \sa SDL_asinf
  1589. * \sa SDL_cosf
  1590. */
  1591. extern SDL_DECLSPEC float SDLCALL SDL_acosf(float x);
  1592. /**
  1593. * Compute the arc sine of `x`.
  1594. *
  1595. * The definition of `y = asin(x)` is `x = sin(y)`.
  1596. *
  1597. * Domain: `-1 <= x <= 1`
  1598. *
  1599. * Range: `-Pi/2 <= y <= Pi/2`
  1600. *
  1601. * This function operates on double-precision floating point values, use
  1602. * SDL_asinf for single-precision floats.
  1603. *
  1604. * This function may use a different approximation across different versions,
  1605. * platforms and configurations. i.e, it can return a different value given
  1606. * the same input on different machines or operating systems, or if SDL is
  1607. * updated.
  1608. *
  1609. * \param x floating point value.
  1610. * \returns arc sine of `x`, in radians.
  1611. *
  1612. * \threadsafety It is safe to call this function from any thread.
  1613. *
  1614. * \since This function is available since SDL 3.0.0.
  1615. *
  1616. * \sa SDL_asinf
  1617. * \sa SDL_acos
  1618. * \sa SDL_sin
  1619. */
  1620. extern SDL_DECLSPEC double SDLCALL SDL_asin(double x);
  1621. /**
  1622. * Compute the arc sine of `x`.
  1623. *
  1624. * The definition of `y = asin(x)` is `x = sin(y)`.
  1625. *
  1626. * Domain: `-1 <= x <= 1`
  1627. *
  1628. * Range: `-Pi/2 <= y <= Pi/2`
  1629. *
  1630. * This function operates on single-precision floating point values, use
  1631. * SDL_asin for double-precision floats.
  1632. *
  1633. * This function may use a different approximation across different versions,
  1634. * platforms and configurations. i.e, it can return a different value given
  1635. * the same input on different machines or operating systems, or if SDL is
  1636. * updated.
  1637. *
  1638. * \param x floating point value.
  1639. * \returns arc sine of `x`, in radians.
  1640. *
  1641. * \threadsafety It is safe to call this function from any thread.
  1642. *
  1643. * \since This function is available since SDL 3.0.0.
  1644. *
  1645. * \sa SDL_asin
  1646. * \sa SDL_acosf
  1647. * \sa SDL_sinf
  1648. */
  1649. extern SDL_DECLSPEC float SDLCALL SDL_asinf(float x);
  1650. /**
  1651. * Compute the arc tangent of `x`.
  1652. *
  1653. * The definition of `y = atan(x)` is `x = tan(y)`.
  1654. *
  1655. * Domain: `-INF <= x <= INF`
  1656. *
  1657. * Range: `-Pi/2 <= y <= Pi/2`
  1658. *
  1659. * This function operates on double-precision floating point values, use
  1660. * SDL_atanf for single-precision floats.
  1661. *
  1662. * To calculate the arc tangent of y / x, use SDL_atan2.
  1663. *
  1664. * This function may use a different approximation across different versions,
  1665. * platforms and configurations. i.e, it can return a different value given
  1666. * the same input on different machines or operating systems, or if SDL is
  1667. * updated.
  1668. *
  1669. * \param x floating point value.
  1670. * \returns arc tangent of of `x` in radians, or 0 if `x = 0`.
  1671. *
  1672. * \threadsafety It is safe to call this function from any thread.
  1673. *
  1674. * \since This function is available since SDL 3.0.0.
  1675. *
  1676. * \sa SDL_atanf
  1677. * \sa SDL_atan2
  1678. * \sa SDL_tan
  1679. */
  1680. extern SDL_DECLSPEC double SDLCALL SDL_atan(double x);
  1681. /**
  1682. * Compute the arc tangent of `x`.
  1683. *
  1684. * The definition of `y = atan(x)` is `x = tan(y)`.
  1685. *
  1686. * Domain: `-INF <= x <= INF`
  1687. *
  1688. * Range: `-Pi/2 <= y <= Pi/2`
  1689. *
  1690. * This function operates on single-precision floating point values, use
  1691. * SDL_atan for dboule-precision floats.
  1692. *
  1693. * To calculate the arc tangent of y / x, use SDL_atan2f.
  1694. *
  1695. * This function may use a different approximation across different versions,
  1696. * platforms and configurations. i.e, it can return a different value given
  1697. * the same input on different machines or operating systems, or if SDL is
  1698. * updated.
  1699. *
  1700. * \param x floating point value.
  1701. * \returns arc tangent of of `x` in radians, or 0 if `x = 0`.
  1702. *
  1703. * \threadsafety It is safe to call this function from any thread.
  1704. *
  1705. * \since This function is available since SDL 3.0.0.
  1706. *
  1707. * \sa SDL_atan
  1708. * \sa SDL_atan2f
  1709. * \sa SDL_tanf
  1710. */
  1711. extern SDL_DECLSPEC float SDLCALL SDL_atanf(float x);
  1712. /**
  1713. * Compute the arc tangent of `y / x`, using the signs of x and y to adjust
  1714. * the result's quadrant.
  1715. *
  1716. * The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant
  1717. * of z is determined based on the signs of x and y.
  1718. *
  1719. * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
  1720. *
  1721. * Range: `-Pi/2 <= y <= Pi/2`
  1722. *
  1723. * This function operates on double-precision floating point values, use
  1724. * SDL_atan2f for single-precision floats.
  1725. *
  1726. * To calculate the arc tangent of a single value, use SDL_atan.
  1727. *
  1728. * This function may use a different approximation across different versions,
  1729. * platforms and configurations. i.e, it can return a different value given
  1730. * the same input on different machines or operating systems, or if SDL is
  1731. * updated.
  1732. *
  1733. * \param y floating point value of the numerator (y coordinate).
  1734. * \param x floating point value of the denominator (x coordinate).
  1735. * \returns arc tangent of of `y / x` in radians, or, if `x = 0`, either
  1736. * `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`.
  1737. *
  1738. * \threadsafety It is safe to call this function from any thread.
  1739. *
  1740. * \since This function is available since SDL 3.0.0.
  1741. *
  1742. * \sa SDL_atan2f
  1743. * \sa SDL_atan
  1744. * \sa SDL_tan
  1745. */
  1746. extern SDL_DECLSPEC double SDLCALL SDL_atan2(double y, double x);
  1747. /**
  1748. * Compute the arc tangent of `y / x`, using the signs of x and y to adjust
  1749. * the result's quadrant.
  1750. *
  1751. * The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant
  1752. * of z is determined based on the signs of x and y.
  1753. *
  1754. * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
  1755. *
  1756. * Range: `-Pi/2 <= y <= Pi/2`
  1757. *
  1758. * This function operates on single-precision floating point values, use
  1759. * SDL_atan2 for double-precision floats.
  1760. *
  1761. * To calculate the arc tangent of a single value, use SDL_atanf.
  1762. *
  1763. * This function may use a different approximation across different versions,
  1764. * platforms and configurations. i.e, it can return a different value given
  1765. * the same input on different machines or operating systems, or if SDL is
  1766. * updated.
  1767. *
  1768. * \param y floating point value of the numerator (y coordinate).
  1769. * \param x floating point value of the denominator (x coordinate).
  1770. * \returns arc tangent of of `y / x` in radians, or, if `x = 0`, either
  1771. * `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`.
  1772. *
  1773. * \threadsafety It is safe to call this function from any thread.
  1774. *
  1775. * \since This function is available since SDL 3.0.0.
  1776. *
  1777. * \sa SDL_atan2f
  1778. * \sa SDL_atan
  1779. * \sa SDL_tan
  1780. */
  1781. extern SDL_DECLSPEC float SDLCALL SDL_atan2f(float y, float x);
  1782. /**
  1783. * Compute the ceiling of `x`.
  1784. *
  1785. * The ceiling of `x` is the smallest integer `y` such that `y > x`, i.e `x`
  1786. * rounded up to the nearest integer.
  1787. *
  1788. * Domain: `-INF <= x <= INF`
  1789. *
  1790. * Range: `-INF <= y <= INF`, y integer
  1791. *
  1792. * This function operates on double-precision floating point values, use
  1793. * SDL_ceilf for single-precision floats.
  1794. *
  1795. * \param x floating point value.
  1796. * \returns the ceiling of `x`.
  1797. *
  1798. * \threadsafety It is safe to call this function from any thread.
  1799. *
  1800. * \since This function is available since SDL 3.0.0.
  1801. *
  1802. * \sa SDL_ceilf
  1803. * \sa SDL_floor
  1804. * \sa SDL_trunc
  1805. * \sa SDL_round
  1806. * \sa SDL_lround
  1807. */
  1808. extern SDL_DECLSPEC double SDLCALL SDL_ceil(double x);
  1809. /**
  1810. * Compute the ceiling of `x`.
  1811. *
  1812. * The ceiling of `x` is the smallest integer `y` such that `y > x`, i.e `x`
  1813. * rounded up to the nearest integer.
  1814. *
  1815. * Domain: `-INF <= x <= INF`
  1816. *
  1817. * Range: `-INF <= y <= INF`, y integer
  1818. *
  1819. * This function operates on single-precision floating point values, use
  1820. * SDL_ceil for double-precision floats.
  1821. *
  1822. * \param x floating point value.
  1823. * \returns the ceiling of `x`.
  1824. *
  1825. * \threadsafety It is safe to call this function from any thread.
  1826. *
  1827. * \since This function is available since SDL 3.0.0.
  1828. *
  1829. * \sa SDL_ceil
  1830. * \sa SDL_floorf
  1831. * \sa SDL_truncf
  1832. * \sa SDL_roundf
  1833. * \sa SDL_lroundf
  1834. */
  1835. extern SDL_DECLSPEC float SDLCALL SDL_ceilf(float x);
  1836. /**
  1837. * Copy the sign of one floating-point value to another.
  1838. *
  1839. * The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``.
  1840. *
  1841. * Domain: `-INF <= x <= INF`, ``-INF <= y <= f``
  1842. *
  1843. * Range: `-INF <= z <= INF`
  1844. *
  1845. * This function operates on double-precision floating point values, use
  1846. * SDL_copysignf for single-precision floats.
  1847. *
  1848. * \param x floating point value to use as the magnitude.
  1849. * \param y floating point value to use as the sign.
  1850. * \returns the floating point value with the sign of y and the magnitude of
  1851. * x.
  1852. *
  1853. * \threadsafety It is safe to call this function from any thread.
  1854. *
  1855. * \since This function is available since SDL 3.0.0.
  1856. *
  1857. * \sa SDL_copysignf
  1858. * \sa SDL_fabs
  1859. */
  1860. extern SDL_DECLSPEC double SDLCALL SDL_copysign(double x, double y);
  1861. /**
  1862. * Copy the sign of one floating-point value to another.
  1863. *
  1864. * The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``.
  1865. *
  1866. * Domain: `-INF <= x <= INF`, ``-INF <= y <= f``
  1867. *
  1868. * Range: `-INF <= z <= INF`
  1869. *
  1870. * This function operates on single-precision floating point values, use
  1871. * SDL_copysign for double-precision floats.
  1872. *
  1873. * \param x floating point value to use as the magnitude.
  1874. * \param y floating point value to use as the sign.
  1875. * \returns the floating point value with the sign of y and the magnitude of
  1876. * x.
  1877. *
  1878. * \threadsafety It is safe to call this function from any thread.
  1879. *
  1880. * \since This function is available since SDL 3.0.0.
  1881. *
  1882. * \sa SDL_copysignf
  1883. * \sa SDL_fabsf
  1884. */
  1885. extern SDL_DECLSPEC float SDLCALL SDL_copysignf(float x, float y);
  1886. /**
  1887. * Compute the cosine of `x`.
  1888. *
  1889. * Domain: `-INF <= x <= INF`
  1890. *
  1891. * Range: `-1 <= y <= 1`
  1892. *
  1893. * This function operates on double-precision floating point values, use
  1894. * SDL_cosf for single-precision floats.
  1895. *
  1896. * This function may use a different approximation across different versions,
  1897. * platforms and configurations. i.e, it can return a different value given
  1898. * the same input on different machines or operating systems, or if SDL is
  1899. * updated.
  1900. *
  1901. * \param x floating point value, in radians.
  1902. * \returns cosine of `x`.
  1903. *
  1904. * \threadsafety It is safe to call this function from any thread.
  1905. *
  1906. * \since This function is available since SDL 3.0.0.
  1907. *
  1908. * \sa SDL_cosf
  1909. * \sa SDL_acos
  1910. * \sa SDL_sin
  1911. */
  1912. extern SDL_DECLSPEC double SDLCALL SDL_cos(double x);
  1913. /**
  1914. * Compute the cosine of `x`.
  1915. *
  1916. * Domain: `-INF <= x <= INF`
  1917. *
  1918. * Range: `-1 <= y <= 1`
  1919. *
  1920. * This function operates on single-precision floating point values, use
  1921. * SDL_cos for double-precision floats.
  1922. *
  1923. * This function may use a different approximation across different versions,
  1924. * platforms and configurations. i.e, it can return a different value given
  1925. * the same input on different machines or operating systems, or if SDL is
  1926. * updated.
  1927. *
  1928. * \param x floating point value, in radians.
  1929. * \returns cosine of `x`.
  1930. *
  1931. * \threadsafety It is safe to call this function from any thread.
  1932. *
  1933. * \since This function is available since SDL 3.0.0.
  1934. *
  1935. * \sa SDL_cos
  1936. * \sa SDL_acosf
  1937. * \sa SDL_sinf
  1938. */
  1939. extern SDL_DECLSPEC float SDLCALL SDL_cosf(float x);
  1940. /**
  1941. * Compute the exponential of `x`.
  1942. *
  1943. * The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the
  1944. * natural logarithm. The inverse is the natural logarithm, SDL_log.
  1945. *
  1946. * Domain: `-INF <= x <= INF`
  1947. *
  1948. * Range: `0 <= y <= INF`
  1949. *
  1950. * The output will overflow if `exp(x)` is too large to be represented.
  1951. *
  1952. * This function operates on double-precision floating point values, use
  1953. * SDL_expf for single-precision floats.
  1954. *
  1955. * This function may use a different approximation across different versions,
  1956. * platforms and configurations. i.e, it can return a different value given
  1957. * the same input on different machines or operating systems, or if SDL is
  1958. * updated.
  1959. *
  1960. * \param x floating point value.
  1961. * \returns value of `e^x`.
  1962. *
  1963. * \threadsafety It is safe to call this function from any thread.
  1964. *
  1965. * \since This function is available since SDL 3.0.0.
  1966. *
  1967. * \sa SDL_expf
  1968. * \sa SDL_log
  1969. */
  1970. extern SDL_DECLSPEC double SDLCALL SDL_exp(double x);
  1971. /**
  1972. * Compute the exponential of `x`.
  1973. *
  1974. * The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the
  1975. * natural logarithm. The inverse is the natural logarithm, SDL_logf.
  1976. *
  1977. * Domain: `-INF <= x <= INF`
  1978. *
  1979. * Range: `0 <= y <= INF`
  1980. *
  1981. * The output will overflow if `exp(x)` is too large to be represented.
  1982. *
  1983. * This function operates on single-precision floating point values, use
  1984. * SDL_exp for double-precision floats.
  1985. *
  1986. * This function may use a different approximation across different versions,
  1987. * platforms and configurations. i.e, it can return a different value given
  1988. * the same input on different machines or operating systems, or if SDL is
  1989. * updated.
  1990. *
  1991. * \param x floating point value.
  1992. * \returns value of `e^x`.
  1993. *
  1994. * \threadsafety It is safe to call this function from any thread.
  1995. *
  1996. * \since This function is available since SDL 3.0.0.
  1997. *
  1998. * \sa SDL_exp
  1999. * \sa SDL_logf
  2000. */
  2001. extern SDL_DECLSPEC float SDLCALL SDL_expf(float x);
  2002. /**
  2003. * Compute the absolute value of `x`
  2004. *
  2005. * Domain: `-INF <= x <= INF`
  2006. *
  2007. * Range: `0 <= y <= INF`
  2008. *
  2009. * This function operates on double-precision floating point values, use
  2010. * SDL_copysignf for single-precision floats.
  2011. *
  2012. * \param x floating point value to use as the magnitude.
  2013. * \returns the absolute value of `x`.
  2014. *
  2015. * \threadsafety It is safe to call this function from any thread.
  2016. *
  2017. * \since This function is available since SDL 3.0.0.
  2018. *
  2019. * \sa SDL_fabsf
  2020. */
  2021. extern SDL_DECLSPEC double SDLCALL SDL_fabs(double x);
  2022. /**
  2023. * Compute the absolute value of `x`
  2024. *
  2025. * Domain: `-INF <= x <= INF`
  2026. *
  2027. * Range: `0 <= y <= INF`
  2028. *
  2029. * This function operates on single-precision floating point values, use
  2030. * SDL_copysignf for double-precision floats.
  2031. *
  2032. * \param x floating point value to use as the magnitude.
  2033. * \returns the absolute value of `x`.
  2034. *
  2035. * \threadsafety It is safe to call this function from any thread.
  2036. *
  2037. * \since This function is available since SDL 3.0.0.
  2038. *
  2039. * \sa SDL_fabs
  2040. */
  2041. extern SDL_DECLSPEC float SDLCALL SDL_fabsf(float x);
  2042. /**
  2043. * Compute the floor of `x`.
  2044. *
  2045. * The floor of `x` is the largest integer `y` such that `y > x`, i.e `x`
  2046. * rounded down to the nearest integer.
  2047. *
  2048. * Domain: `-INF <= x <= INF`
  2049. *
  2050. * Range: `-INF <= y <= INF`, y integer
  2051. *
  2052. * This function operates on double-precision floating point values, use
  2053. * SDL_floorf for single-precision floats.
  2054. *
  2055. * \param x floating point value.
  2056. * \returns the floor of `x`.
  2057. *
  2058. * \threadsafety It is safe to call this function from any thread.
  2059. *
  2060. * \since This function is available since SDL 3.0.0.
  2061. *
  2062. * \sa SDL_floorf
  2063. * \sa SDL_ceil
  2064. * \sa SDL_trunc
  2065. * \sa SDL_round
  2066. * \sa SDL_lround
  2067. */
  2068. extern SDL_DECLSPEC double SDLCALL SDL_floor(double x);
  2069. /**
  2070. * Compute the floor of `x`.
  2071. *
  2072. * The floor of `x` is the largest integer `y` such that `y > x`, i.e `x`
  2073. * rounded down to the nearest integer.
  2074. *
  2075. * Domain: `-INF <= x <= INF`
  2076. *
  2077. * Range: `-INF <= y <= INF`, y integer
  2078. *
  2079. * This function operates on single-precision floating point values, use
  2080. * SDL_floorf for double-precision floats.
  2081. *
  2082. * \param x floating point value.
  2083. * \returns the floor of `x`.
  2084. *
  2085. * \threadsafety It is safe to call this function from any thread.
  2086. *
  2087. * \since This function is available since SDL 3.0.0.
  2088. *
  2089. * \sa SDL_floor
  2090. * \sa SDL_ceilf
  2091. * \sa SDL_truncf
  2092. * \sa SDL_roundf
  2093. * \sa SDL_lroundf
  2094. */
  2095. extern SDL_DECLSPEC float SDLCALL SDL_floorf(float x);
  2096. /**
  2097. * Truncate `x` to an integer.
  2098. *
  2099. * Rounds `x` to the next closest integer to 0. This is equivalent to removing
  2100. * the fractional part of `x`, leaving only the integer part.
  2101. *
  2102. * Domain: `-INF <= x <= INF`
  2103. *
  2104. * Range: `-INF <= y <= INF`, y integer
  2105. *
  2106. * This function operates on double-precision floating point values, use
  2107. * SDL_truncf for single-precision floats.
  2108. *
  2109. * \param x floating point value.
  2110. * \returns `x` truncated to an integer.
  2111. *
  2112. * \threadsafety It is safe to call this function from any thread.
  2113. *
  2114. * \since This function is available since SDL 3.0.0.
  2115. *
  2116. * \sa SDL_truncf
  2117. * \sa SDL_fmod
  2118. * \sa SDL_ceil
  2119. * \sa SDL_floor
  2120. * \sa SDL_round
  2121. * \sa SDL_lround
  2122. */
  2123. extern SDL_DECLSPEC double SDLCALL SDL_trunc(double x);
  2124. /**
  2125. * Truncate `x` to an integer.
  2126. *
  2127. * Rounds `x` to the next closest integer to 0. This is equivalent to removing
  2128. * the fractional part of `x`, leaving only the integer part.
  2129. *
  2130. * Domain: `-INF <= x <= INF`
  2131. *
  2132. * Range: `-INF <= y <= INF`, y integer
  2133. *
  2134. * This function operates on single-precision floating point values, use
  2135. * SDL_truncf for double-precision floats.
  2136. *
  2137. * \param x floating point value.
  2138. * \returns `x` truncated to an integer.
  2139. *
  2140. * \threadsafety It is safe to call this function from any thread.
  2141. *
  2142. * \since This function is available since SDL 3.0.0.
  2143. *
  2144. * \sa SDL_trunc
  2145. * \sa SDL_fmodf
  2146. * \sa SDL_ceilf
  2147. * \sa SDL_floorf
  2148. * \sa SDL_roundf
  2149. * \sa SDL_lroundf
  2150. */
  2151. extern SDL_DECLSPEC float SDLCALL SDL_truncf(float x);
  2152. /**
  2153. * Return the floating-point remainder of `x / y`
  2154. *
  2155. * Divides `x` by `y`, and returns the remainder.
  2156. *
  2157. * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0`
  2158. *
  2159. * Range: `-y <= z <= y`
  2160. *
  2161. * This function operates on double-precision floating point values, use
  2162. * SDL_fmodf for single-precision floats.
  2163. *
  2164. * \param x the numerator.
  2165. * \param y the denominator. Must not be 0.
  2166. * \returns the remainder of `x / y`.
  2167. *
  2168. * \threadsafety It is safe to call this function from any thread.
  2169. *
  2170. * \since This function is available since SDL 3.0.0.
  2171. *
  2172. * \sa SDL_fmodf
  2173. * \sa SDL_modf
  2174. * \sa SDL_trunc
  2175. * \sa SDL_ceil
  2176. * \sa SDL_floor
  2177. * \sa SDL_round
  2178. * \sa SDL_lround
  2179. */
  2180. extern SDL_DECLSPEC double SDLCALL SDL_fmod(double x, double y);
  2181. /**
  2182. * Return the floating-point remainder of `x / y`
  2183. *
  2184. * Divides `x` by `y`, and returns the remainder.
  2185. *
  2186. * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0`
  2187. *
  2188. * Range: `-y <= z <= y`
  2189. *
  2190. * This function operates on single-precision floating point values, use
  2191. * SDL_fmod for single-precision floats.
  2192. *
  2193. * \param x the numerator.
  2194. * \param y the denominator. Must not be 0.
  2195. * \returns the remainder of `x / y`.
  2196. *
  2197. * \threadsafety It is safe to call this function from any thread.
  2198. *
  2199. * \since This function is available since SDL 3.0.0.
  2200. *
  2201. * \sa SDL_fmod
  2202. * \sa SDL_truncf
  2203. * \sa SDL_modff
  2204. * \sa SDL_ceilf
  2205. * \sa SDL_floorf
  2206. * \sa SDL_roundf
  2207. * \sa SDL_lroundf
  2208. */
  2209. extern SDL_DECLSPEC float SDLCALL SDL_fmodf(float x, float y);
  2210. /**
  2211. * Return whether the value is infinity.
  2212. *
  2213. * \param x double-precision floating point value.
  2214. * \returns non-zero if the value is infinity, 0 otherwise.
  2215. *
  2216. * \threadsafety It is safe to call this function from any thread.
  2217. *
  2218. * \since This function is available since SDL 3.0.0.
  2219. *
  2220. * \sa SDL_isinff
  2221. */
  2222. extern SDL_DECLSPEC int SDLCALL SDL_isinf(double x);
  2223. /**
  2224. * Return whether the value is infinity.
  2225. *
  2226. * \param x floating point value.
  2227. * \returns non-zero if the value is infinity, 0 otherwise.
  2228. *
  2229. * \threadsafety It is safe to call this function from any thread.
  2230. *
  2231. * \since This function is available since SDL 3.0.0.
  2232. *
  2233. * \sa SDL_isinf
  2234. */
  2235. extern SDL_DECLSPEC int SDLCALL SDL_isinff(float x);
  2236. /**
  2237. * Return whether the value is NaN.
  2238. *
  2239. * \param x double-precision floating point value.
  2240. * \returns non-zero if the value is NaN, 0 otherwise.
  2241. *
  2242. * \threadsafety It is safe to call this function from any thread.
  2243. *
  2244. * \since This function is available since SDL 3.0.0.
  2245. *
  2246. * \sa SDL_isnanf
  2247. */
  2248. extern SDL_DECLSPEC int SDLCALL SDL_isnan(double x);
  2249. /**
  2250. * Return whether the value is NaN.
  2251. *
  2252. * \param x floating point value.
  2253. * \returns non-zero if the value is NaN, 0 otherwise.
  2254. *
  2255. * \threadsafety It is safe to call this function from any thread.
  2256. *
  2257. * \since This function is available since SDL 3.0.0.
  2258. *
  2259. * \sa SDL_isnan
  2260. */
  2261. extern SDL_DECLSPEC int SDLCALL SDL_isnanf(float x);
  2262. /**
  2263. * Compute the natural logarithm of `x`.
  2264. *
  2265. * Domain: `0 < x <= INF`
  2266. *
  2267. * Range: `-INF <= y <= INF`
  2268. *
  2269. * It is an error for `x` to be less than or equal to 0.
  2270. *
  2271. * This function operates on double-precision floating point values, use
  2272. * SDL_logf for single-precision floats.
  2273. *
  2274. * This function may use a different approximation across different versions,
  2275. * platforms and configurations. i.e, it can return a different value given
  2276. * the same input on different machines or operating systems, or if SDL is
  2277. * updated.
  2278. *
  2279. * \param x floating point value. Must be greater than 0.
  2280. * \returns the natural logarithm of `x`.
  2281. *
  2282. * \threadsafety It is safe to call this function from any thread.
  2283. *
  2284. * \since This function is available since SDL 3.0.0.
  2285. *
  2286. * \sa SDL_logf
  2287. * \sa SDL_log10
  2288. * \sa SDL_exp
  2289. */
  2290. extern SDL_DECLSPEC double SDLCALL SDL_log(double x);
  2291. /**
  2292. * Compute the natural logarithm of `x`.
  2293. *
  2294. * Domain: `0 < x <= INF`
  2295. *
  2296. * Range: `-INF <= y <= INF`
  2297. *
  2298. * It is an error for `x` to be less than or equal to 0.
  2299. *
  2300. * This function operates on single-precision floating point values, use
  2301. * SDL_log for double-precision floats.
  2302. *
  2303. * This function may use a different approximation across different versions,
  2304. * platforms and configurations. i.e, it can return a different value given
  2305. * the same input on different machines or operating systems, or if SDL is
  2306. * updated.
  2307. *
  2308. * \param x floating point value. Must be greater than 0.
  2309. * \returns the natural logarithm of `x`.
  2310. *
  2311. * \threadsafety It is safe to call this function from any thread.
  2312. *
  2313. * \since This function is available since SDL 3.0.0.
  2314. *
  2315. * \sa SDL_log
  2316. * \sa SDL_expf
  2317. */
  2318. extern SDL_DECLSPEC float SDLCALL SDL_logf(float x);
  2319. /**
  2320. * Compute the base-10 logarithm of `x`.
  2321. *
  2322. * Domain: `0 < x <= INF`
  2323. *
  2324. * Range: `-INF <= y <= INF`
  2325. *
  2326. * It is an error for `x` to be less than or equal to 0.
  2327. *
  2328. * This function operates on double-precision floating point values, use
  2329. * SDL_log10f for single-precision floats.
  2330. *
  2331. * This function may use a different approximation across different versions,
  2332. * platforms and configurations. i.e, it can return a different value given
  2333. * the same input on different machines or operating systems, or if SDL is
  2334. * updated.
  2335. *
  2336. * \param x floating point value. Must be greater than 0.
  2337. * \returns the logarithm of `x`.
  2338. *
  2339. * \threadsafety It is safe to call this function from any thread.
  2340. *
  2341. * \since This function is available since SDL 3.0.0.
  2342. *
  2343. * \sa SDL_log10f
  2344. * \sa SDL_log
  2345. * \sa SDL_pow
  2346. */
  2347. extern SDL_DECLSPEC double SDLCALL SDL_log10(double x);
  2348. /**
  2349. * Compute the base-10 logarithm of `x`.
  2350. *
  2351. * Domain: `0 < x <= INF`
  2352. *
  2353. * Range: `-INF <= y <= INF`
  2354. *
  2355. * It is an error for `x` to be less than or equal to 0.
  2356. *
  2357. * This function operates on single-precision floating point values, use
  2358. * SDL_log10 for double-precision floats.
  2359. *
  2360. * This function may use a different approximation across different versions,
  2361. * platforms and configurations. i.e, it can return a different value given
  2362. * the same input on different machines or operating systems, or if SDL is
  2363. * updated.
  2364. *
  2365. * \param x floating point value. Must be greater than 0.
  2366. * \returns the logarithm of `x`.
  2367. *
  2368. * \threadsafety It is safe to call this function from any thread.
  2369. *
  2370. * \since This function is available since SDL 3.0.0.
  2371. *
  2372. * \sa SDL_log10
  2373. * \sa SDL_logf
  2374. * \sa SDL_powf
  2375. */
  2376. extern SDL_DECLSPEC float SDLCALL SDL_log10f(float x);
  2377. /**
  2378. * Split `x` into integer and fractional parts
  2379. *
  2380. * This function operates on double-precision floating point values, use
  2381. * SDL_modff for single-precision floats.
  2382. *
  2383. * \param x floating point value.
  2384. * \param y output pointer to store the integer part of `x`.
  2385. * \returns the fractional part of `x`.
  2386. *
  2387. * \threadsafety It is safe to call this function from any thread.
  2388. *
  2389. * \since This function is available since SDL 3.0.0.
  2390. *
  2391. * \sa SDL_modff
  2392. * \sa SDL_trunc
  2393. * \sa SDL_fmod
  2394. */
  2395. extern SDL_DECLSPEC double SDLCALL SDL_modf(double x, double *y);
  2396. /**
  2397. * Split `x` into integer and fractional parts
  2398. *
  2399. * This function operates on single-precision floating point values, use
  2400. * SDL_modf for double-precision floats.
  2401. *
  2402. * \param x floating point value.
  2403. * \param y output pointer to store the integer part of `x`.
  2404. * \returns the fractional part of `x`.
  2405. *
  2406. * \threadsafety It is safe to call this function from any thread.
  2407. *
  2408. * \since This function is available since SDL 3.0.0.
  2409. *
  2410. * \sa SDL_modf
  2411. * \sa SDL_truncf
  2412. * \sa SDL_fmodf
  2413. */
  2414. extern SDL_DECLSPEC float SDLCALL SDL_modff(float x, float *y);
  2415. /**
  2416. * Raise `x` to the power `y`
  2417. *
  2418. * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
  2419. *
  2420. * Range: `-INF <= z <= INF`
  2421. *
  2422. * If `y` is the base of the natural logarithm (e), consider using SDL_exp
  2423. * instead.
  2424. *
  2425. * This function operates on double-precision floating point values, use
  2426. * SDL_powf for single-precision floats.
  2427. *
  2428. * This function may use a different approximation across different versions,
  2429. * platforms and configurations. i.e, it can return a different value given
  2430. * the same input on different machines or operating systems, or if SDL is
  2431. * updated.
  2432. *
  2433. * \param x the base.
  2434. * \param y the exponent.
  2435. * \returns `x` raised to the power `y`.
  2436. *
  2437. * \threadsafety It is safe to call this function from any thread.
  2438. *
  2439. * \since This function is available since SDL 3.0.0.
  2440. *
  2441. * \sa SDL_powf
  2442. * \sa SDL_exp
  2443. * \sa SDL_log
  2444. */
  2445. extern SDL_DECLSPEC double SDLCALL SDL_pow(double x, double y);
  2446. /**
  2447. * Raise `x` to the power `y`
  2448. *
  2449. * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
  2450. *
  2451. * Range: `-INF <= z <= INF`
  2452. *
  2453. * If `y` is the base of the natural logarithm (e), consider using SDL_exp
  2454. * instead.
  2455. *
  2456. * This function operates on single-precision floating point values, use
  2457. * SDL_powf for double-precision floats.
  2458. *
  2459. * This function may use a different approximation across different versions,
  2460. * platforms and configurations. i.e, it can return a different value given
  2461. * the same input on different machines or operating systems, or if SDL is
  2462. * updated.
  2463. *
  2464. * \param x the base.
  2465. * \param y the exponent.
  2466. * \returns `x` raised to the power `y`.
  2467. *
  2468. * \threadsafety It is safe to call this function from any thread.
  2469. *
  2470. * \since This function is available since SDL 3.0.0.
  2471. *
  2472. * \sa SDL_pow
  2473. * \sa SDL_expf
  2474. * \sa SDL_logf
  2475. */
  2476. extern SDL_DECLSPEC float SDLCALL SDL_powf(float x, float y);
  2477. /**
  2478. * Round `x` to the nearest integer.
  2479. *
  2480. * Rounds `x` to the nearest integer. Values halfway between integers will be
  2481. * rounded away from zero.
  2482. *
  2483. * Domain: `-INF <= x <= INF`
  2484. *
  2485. * Range: `-INF <= y <= INF`, y integer
  2486. *
  2487. * This function operates on double-precision floating point values, use
  2488. * SDL_roundf for single-precision floats. To get the result as an integer
  2489. * type, use SDL_lround.
  2490. *
  2491. * \param x floating point value.
  2492. * \returns the nearest integer to `x`.
  2493. *
  2494. * \threadsafety It is safe to call this function from any thread.
  2495. *
  2496. * \since This function is available since SDL 3.0.0.
  2497. *
  2498. * \sa SDL_roundf
  2499. * \sa SDL_lround
  2500. * \sa SDL_floor
  2501. * \sa SDL_ceil
  2502. * \sa SDL_trunc
  2503. */
  2504. extern SDL_DECLSPEC double SDLCALL SDL_round(double x);
  2505. /**
  2506. * Round `x` to the nearest integer.
  2507. *
  2508. * Rounds `x` to the nearest integer. Values halfway between integers will be
  2509. * rounded away from zero.
  2510. *
  2511. * Domain: `-INF <= x <= INF`
  2512. *
  2513. * Range: `-INF <= y <= INF`, y integer
  2514. *
  2515. * This function operates on double-precision floating point values, use
  2516. * SDL_roundf for single-precision floats. To get the result as an integer
  2517. * type, use SDL_lroundf.
  2518. *
  2519. * \param x floating point value.
  2520. * \returns the nearest integer to `x`.
  2521. *
  2522. * \threadsafety It is safe to call this function from any thread.
  2523. *
  2524. * \since This function is available since SDL 3.0.0.
  2525. *
  2526. * \sa SDL_round
  2527. * \sa SDL_lroundf
  2528. * \sa SDL_floorf
  2529. * \sa SDL_ceilf
  2530. * \sa SDL_truncf
  2531. */
  2532. extern SDL_DECLSPEC float SDLCALL SDL_roundf(float x);
  2533. /**
  2534. * Round `x` to the nearest integer representable as a long
  2535. *
  2536. * Rounds `x` to the nearest integer. Values halfway between integers will be
  2537. * rounded away from zero.
  2538. *
  2539. * Domain: `-INF <= x <= INF`
  2540. *
  2541. * Range: `MIN_LONG <= y <= MAX_LONG`
  2542. *
  2543. * This function operates on double-precision floating point values, use
  2544. * SDL_lround for single-precision floats. To get the result as a
  2545. * floating-point type, use SDL_round.
  2546. *
  2547. * \param x floating point value.
  2548. * \returns the nearest integer to `x`.
  2549. *
  2550. * \threadsafety It is safe to call this function from any thread.
  2551. *
  2552. * \since This function is available since SDL 3.0.0.
  2553. *
  2554. * \sa SDL_lroundf
  2555. * \sa SDL_round
  2556. * \sa SDL_floor
  2557. * \sa SDL_ceil
  2558. * \sa SDL_trunc
  2559. */
  2560. extern SDL_DECLSPEC long SDLCALL SDL_lround(double x);
  2561. /**
  2562. * Round `x` to the nearest integer representable as a long
  2563. *
  2564. * Rounds `x` to the nearest integer. Values halfway between integers will be
  2565. * rounded away from zero.
  2566. *
  2567. * Domain: `-INF <= x <= INF`
  2568. *
  2569. * Range: `MIN_LONG <= y <= MAX_LONG`
  2570. *
  2571. * This function operates on single-precision floating point values, use
  2572. * SDL_lroundf for double-precision floats. To get the result as a
  2573. * floating-point type, use SDL_roundf,
  2574. *
  2575. * \param x floating point value.
  2576. * \returns the nearest integer to `x`.
  2577. *
  2578. * \threadsafety It is safe to call this function from any thread.
  2579. *
  2580. * \since This function is available since SDL 3.0.0.
  2581. *
  2582. * \sa SDL_lround
  2583. * \sa SDL_roundf
  2584. * \sa SDL_floorf
  2585. * \sa SDL_ceilf
  2586. * \sa SDL_truncf
  2587. */
  2588. extern SDL_DECLSPEC long SDLCALL SDL_lroundf(float x);
  2589. /**
  2590. * Scale `x` by an integer power of two.
  2591. *
  2592. * Multiplies `x` by the `n`th power of the floating point radix (always 2).
  2593. *
  2594. * Domain: `-INF <= x <= INF`, `n` integer
  2595. *
  2596. * Range: `-INF <= y <= INF`
  2597. *
  2598. * This function operates on double-precision floating point values, use
  2599. * SDL_scalbnf for single-precision floats.
  2600. *
  2601. * \param x floating point value to be scaled.
  2602. * \param n integer exponent.
  2603. * \returns `x * 2^n`.
  2604. *
  2605. * \threadsafety It is safe to call this function from any thread.
  2606. *
  2607. * \since This function is available since SDL 3.0.0.
  2608. *
  2609. * \sa SDL_scalbnf
  2610. * \sa SDL_pow
  2611. */
  2612. extern SDL_DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
  2613. /**
  2614. * Scale `x` by an integer power of two.
  2615. *
  2616. * Multiplies `x` by the `n`th power of the floating point radix (always 2).
  2617. *
  2618. * Domain: `-INF <= x <= INF`, `n` integer
  2619. *
  2620. * Range: `-INF <= y <= INF`
  2621. *
  2622. * This function operates on single-precision floating point values, use
  2623. * SDL_scalbn for double-precision floats.
  2624. *
  2625. * \param x floating point value to be scaled.
  2626. * \param n integer exponent.
  2627. * \returns `x * 2^n`.
  2628. *
  2629. * \threadsafety It is safe to call this function from any thread.
  2630. *
  2631. * \since This function is available since SDL 3.0.0.
  2632. *
  2633. * \sa SDL_scalbn
  2634. * \sa SDL_powf
  2635. */
  2636. extern SDL_DECLSPEC float SDLCALL SDL_scalbnf(float x, int n);
  2637. /**
  2638. * Compute the sine of `x`.
  2639. *
  2640. * Domain: `-INF <= x <= INF`
  2641. *
  2642. * Range: `-1 <= y <= 1`
  2643. *
  2644. * This function operates on double-precision floating point values, use
  2645. * SDL_sinf for single-precision floats.
  2646. *
  2647. * This function may use a different approximation across different versions,
  2648. * platforms and configurations. i.e, it can return a different value given
  2649. * the same input on different machines or operating systems, or if SDL is
  2650. * updated.
  2651. *
  2652. * \param x floating point value, in radians.
  2653. * \returns sine of `x`.
  2654. *
  2655. * \threadsafety It is safe to call this function from any thread.
  2656. *
  2657. * \since This function is available since SDL 3.0.0.
  2658. *
  2659. * \sa SDL_sinf
  2660. * \sa SDL_asin
  2661. * \sa SDL_cos
  2662. */
  2663. extern SDL_DECLSPEC double SDLCALL SDL_sin(double x);
  2664. /**
  2665. * Compute the sine of `x`.
  2666. *
  2667. * Domain: `-INF <= x <= INF`
  2668. *
  2669. * Range: `-1 <= y <= 1`
  2670. *
  2671. * This function operates on single-precision floating point values, use
  2672. * SDL_sinf for double-precision floats.
  2673. *
  2674. * This function may use a different approximation across different versions,
  2675. * platforms and configurations. i.e, it can return a different value given
  2676. * the same input on different machines or operating systems, or if SDL is
  2677. * updated.
  2678. *
  2679. * \param x floating point value, in radians.
  2680. * \returns sine of `x`.
  2681. *
  2682. * \threadsafety It is safe to call this function from any thread.
  2683. *
  2684. * \since This function is available since SDL 3.0.0.
  2685. *
  2686. * \sa SDL_sin
  2687. * \sa SDL_asinf
  2688. * \sa SDL_cosf
  2689. */
  2690. extern SDL_DECLSPEC float SDLCALL SDL_sinf(float x);
  2691. /**
  2692. * Compute the square root of `x`.
  2693. *
  2694. * Domain: `0 <= x <= INF`
  2695. *
  2696. * Range: `0 <= y <= INF`
  2697. *
  2698. * This function operates on double-precision floating point values, use
  2699. * SDL_sqrtf for single-precision floats.
  2700. *
  2701. * This function may use a different approximation across different versions,
  2702. * platforms and configurations. i.e, it can return a different value given
  2703. * the same input on different machines or operating systems, or if SDL is
  2704. * updated.
  2705. *
  2706. * \param x floating point value. Must be greater than or equal to 0.
  2707. * \returns square root of `x`.
  2708. *
  2709. * \threadsafety It is safe to call this function from any thread.
  2710. *
  2711. * \since This function is available since SDL 3.0.0.
  2712. *
  2713. * \sa SDL_sqrtf
  2714. */
  2715. extern SDL_DECLSPEC double SDLCALL SDL_sqrt(double x);
  2716. /**
  2717. * Compute the square root of `x`.
  2718. *
  2719. * Domain: `0 <= x <= INF`
  2720. *
  2721. * Range: `0 <= y <= INF`
  2722. *
  2723. * This function operates on single-precision floating point values, use
  2724. * SDL_sqrt for double-precision floats.
  2725. *
  2726. * This function may use a different approximation across different versions,
  2727. * platforms and configurations. i.e, it can return a different value given
  2728. * the same input on different machines or operating systems, or if SDL is
  2729. * updated.
  2730. *
  2731. * \param x floating point value. Must be greater than or equal to 0.
  2732. * \returns square root of `x`.
  2733. *
  2734. * \threadsafety It is safe to call this function from any thread.
  2735. *
  2736. * \since This function is available since SDL 3.0.0.
  2737. *
  2738. * \sa SDL_sqrt
  2739. */
  2740. extern SDL_DECLSPEC float SDLCALL SDL_sqrtf(float x);
  2741. /**
  2742. * Compute the tangent of `x`.
  2743. *
  2744. * Domain: `-INF <= x <= INF`
  2745. *
  2746. * Range: `-INF <= y <= INF`
  2747. *
  2748. * This function operates on double-precision floating point values, use
  2749. * SDL_tanf for single-precision floats.
  2750. *
  2751. * This function may use a different approximation across different versions,
  2752. * platforms and configurations. i.e, it can return a different value given
  2753. * the same input on different machines or operating systems, or if SDL is
  2754. * updated.
  2755. *
  2756. * \param x floating point value, in radians.
  2757. * \returns tangent of `x`.
  2758. *
  2759. * \threadsafety It is safe to call this function from any thread.
  2760. *
  2761. * \since This function is available since SDL 3.0.0.
  2762. *
  2763. * \sa SDL_tanf
  2764. * \sa SDL_sin
  2765. * \sa SDL_cos
  2766. * \sa SDL_atan
  2767. * \sa SDL_atan2
  2768. */
  2769. extern SDL_DECLSPEC double SDLCALL SDL_tan(double x);
  2770. /**
  2771. * Compute the tangent of `x`.
  2772. *
  2773. * Domain: `-INF <= x <= INF`
  2774. *
  2775. * Range: `-INF <= y <= INF`
  2776. *
  2777. * This function operates on single-precision floating point values, use
  2778. * SDL_tanf for double-precision floats.
  2779. *
  2780. * This function may use a different approximation across different versions,
  2781. * platforms and configurations. i.e, it can return a different value given
  2782. * the same input on different machines or operating systems, or if SDL is
  2783. * updated.
  2784. *
  2785. * \param x floating point value, in radians.
  2786. * \returns tangent of `x`.
  2787. *
  2788. * \threadsafety It is safe to call this function from any thread.
  2789. *
  2790. * \since This function is available since SDL 3.0.0.
  2791. *
  2792. * \sa SDL_tan
  2793. * \sa SDL_sinf
  2794. * \sa SDL_cosf
  2795. * \sa SDL_atanf
  2796. * \sa SDL_atan2f
  2797. */
  2798. extern SDL_DECLSPEC float SDLCALL SDL_tanf(float x);
  2799. /* The SDL implementation of iconv() returns these error codes */
  2800. #define SDL_ICONV_ERROR (size_t)-1
  2801. #define SDL_ICONV_E2BIG (size_t)-2
  2802. #define SDL_ICONV_EILSEQ (size_t)-3
  2803. #define SDL_ICONV_EINVAL (size_t)-4
  2804. typedef struct SDL_iconv_data_t *SDL_iconv_t;
  2805. /**
  2806. * This function allocates a context for the specified character set
  2807. * conversion.
  2808. *
  2809. * \param tocode The target character encoding, must not be NULL.
  2810. * \param fromcode The source character encoding, must not be NULL.
  2811. * \returns a handle that must be freed with SDL_iconv_close, or
  2812. * SDL_ICONV_ERROR on failure.
  2813. *
  2814. * \since This function is available since SDL 3.0.0.
  2815. *
  2816. * \sa SDL_iconv
  2817. * \sa SDL_iconv_close
  2818. * \sa SDL_iconv_string
  2819. */
  2820. extern SDL_DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
  2821. const char *fromcode);
  2822. /**
  2823. * This function frees a context used for character set conversion.
  2824. *
  2825. * \param cd The character set conversion handle.
  2826. * \returns 0 on success, or -1 on failure.
  2827. *
  2828. * \since This function is available since SDL 3.0.0.
  2829. *
  2830. * \sa SDL_iconv
  2831. * \sa SDL_iconv_open
  2832. * \sa SDL_iconv_string
  2833. */
  2834. extern SDL_DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
  2835. /**
  2836. * This function converts text between encodings, reading from and writing to
  2837. * a buffer.
  2838. *
  2839. * It returns the number of succesful conversions.
  2840. *
  2841. * \param cd The character set conversion context, created in
  2842. * SDL_iconv_open().
  2843. * \param inbuf Address of variable that points to the first character of the
  2844. * input sequence.
  2845. * \param inbytesleft The number of bytes in the input buffer.
  2846. * \param outbuf Address of variable that points to the output buffer.
  2847. * \param outbytesleft The number of bytes in the output buffer.
  2848. * \returns the number of conversions on success, else SDL_ICONV_E2BIG is
  2849. * returned when the output buffer is too small, or SDL_ICONV_EILSEQ
  2850. * is returned when an invalid input sequence is encountered, or
  2851. * SDL_ICONV_EINVAL is returned when an incomplete input sequence is
  2852. * encountered.
  2853. *
  2854. * On exit:
  2855. *
  2856. * - inbuf will point to the beginning of the next multibyte
  2857. * sequence. On error, this is the location of the problematic
  2858. * input sequence. On success, this is the end of the input
  2859. * sequence. - inbytesleft will be set to the number of bytes left
  2860. * to convert, which will be 0 on success. - outbuf will point to
  2861. * the location where to store the next output byte. - outbytesleft
  2862. * will be set to the number of bytes left in the output buffer.
  2863. *
  2864. * \since This function is available since SDL 3.0.0.
  2865. *
  2866. * \sa SDL_iconv_open
  2867. * \sa SDL_iconv_close
  2868. * \sa SDL_iconv_string
  2869. */
  2870. extern SDL_DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
  2871. size_t *inbytesleft, char **outbuf,
  2872. size_t *outbytesleft);
  2873. /**
  2874. * Helper function to convert a string's encoding in one call.
  2875. *
  2876. * This function converts a buffer or string between encodings in one pass.
  2877. *
  2878. * The string does not need to be NULL-terminated; this function operates on
  2879. * the number of bytes specified in `inbytesleft` whether there is a NULL
  2880. * character anywhere in the buffer.
  2881. *
  2882. * The returned string is owned by the caller, and should be passed to
  2883. * SDL_free when no longer needed.
  2884. *
  2885. * \param tocode the character encoding of the output string. Examples are
  2886. * "UTF-8", "UCS-4", etc.
  2887. * \param fromcode the character encoding of data in `inbuf`.
  2888. * \param inbuf the string to convert to a different encoding.
  2889. * \param inbytesleft the size of the input string _in bytes_.
  2890. * \returns a new string, converted to the new encoding, or NULL on error.
  2891. *
  2892. * \since This function is available since SDL 3.0.0.
  2893. *
  2894. * \sa SDL_iconv_open
  2895. * \sa SDL_iconv_close
  2896. * \sa SDL_iconv
  2897. */
  2898. extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
  2899. const char *fromcode,
  2900. const char *inbuf,
  2901. size_t inbytesleft);
  2902. /* Some helper macros for common cases... */
  2903. #define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
  2904. #define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
  2905. #define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
  2906. #define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t))
  2907. /* force builds using Clang's static analysis tools to use literal C runtime
  2908. here, since there are possibly tests that are ineffective otherwise. */
  2909. #if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
  2910. /* The analyzer knows about strlcpy even when the system doesn't provide it */
  2911. #if !defined(HAVE_STRLCPY) && !defined(strlcpy)
  2912. size_t strlcpy(char *dst, const char *src, size_t size);
  2913. #endif
  2914. /* The analyzer knows about strlcat even when the system doesn't provide it */
  2915. #if !defined(HAVE_STRLCAT) && !defined(strlcat)
  2916. size_t strlcat(char *dst, const char *src, size_t size);
  2917. #endif
  2918. #if !defined(HAVE_WCSLCPY) && !defined(wcslcpy)
  2919. size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
  2920. #endif
  2921. #if !defined(HAVE_WCSLCAT) && !defined(wcslcat)
  2922. size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
  2923. #endif
  2924. /* Starting LLVM 16, the analyser errors out if these functions do not have
  2925. their prototype defined (clang-diagnostic-implicit-function-declaration) */
  2926. #include <stdio.h>
  2927. #include <stdlib.h>
  2928. #include <strings.h>
  2929. #define SDL_malloc malloc
  2930. #define SDL_calloc calloc
  2931. #define SDL_realloc realloc
  2932. #define SDL_free free
  2933. #ifndef SDL_memcpy
  2934. #define SDL_memcpy memcpy
  2935. #endif
  2936. #ifndef SDL_memmove
  2937. #define SDL_memmove memmove
  2938. #endif
  2939. #ifndef SDL_memset
  2940. #define SDL_memset memset
  2941. #endif
  2942. #define SDL_memcmp memcmp
  2943. #define SDL_strlcpy strlcpy
  2944. #define SDL_strlcat strlcat
  2945. #define SDL_strlen strlen
  2946. #define SDL_wcslen wcslen
  2947. #define SDL_wcslcpy wcslcpy
  2948. #define SDL_wcslcat wcslcat
  2949. #define SDL_strdup strdup
  2950. #define SDL_wcsdup wcsdup
  2951. #define SDL_strchr strchr
  2952. #define SDL_strrchr strrchr
  2953. #define SDL_strstr strstr
  2954. #define SDL_wcsstr wcsstr
  2955. #define SDL_strtok_r strtok_r
  2956. #define SDL_strcmp strcmp
  2957. #define SDL_wcscmp wcscmp
  2958. #define SDL_strncmp strncmp
  2959. #define SDL_wcsncmp wcsncmp
  2960. #define SDL_strcasecmp strcasecmp
  2961. #define SDL_strncasecmp strncasecmp
  2962. #define SDL_strpbrk strpbrk
  2963. #define SDL_sscanf sscanf
  2964. #define SDL_vsscanf vsscanf
  2965. #define SDL_snprintf snprintf
  2966. #define SDL_vsnprintf vsnprintf
  2967. #endif
  2968. /**
  2969. * Multiply two integers, checking for overflow.
  2970. *
  2971. * If `a * b` would overflow, return SDL_FALSE.
  2972. *
  2973. * Otherwise store `a * b` via ret and return SDL_TRUE.
  2974. *
  2975. * \param a the multiplicand.
  2976. * \param b the multiplier.
  2977. * \param ret on non-overflow output, stores the multiplication result. May
  2978. * not be NULL.
  2979. * \returns SDL_FALSE on overflow, SDL_TRUE if result is multiplied without
  2980. * overflow.
  2981. *
  2982. * \threadsafety It is safe to call this function from any thread.
  2983. *
  2984. * \since This function is available since SDL 3.0.0.
  2985. */
  2986. SDL_FORCE_INLINE SDL_bool SDL_size_mul_check_overflow(size_t a, size_t b, size_t *ret)
  2987. {
  2988. if (a != 0 && b > SDL_SIZE_MAX / a) {
  2989. return SDL_FALSE;
  2990. }
  2991. *ret = a * b;
  2992. return SDL_TRUE;
  2993. }
  2994. #ifndef SDL_WIKI_DOCUMENTATION_SECTION
  2995. #if SDL_HAS_BUILTIN(__builtin_mul_overflow)
  2996. /* This needs to be wrapped in an inline rather than being a direct #define,
  2997. * because __builtin_mul_overflow() is type-generic, but we want to be
  2998. * consistent about interpreting a and b as size_t. */
  2999. SDL_FORCE_INLINE SDL_bool SDL_size_mul_check_overflow_builtin(size_t a, size_t b, size_t *ret)
  3000. {
  3001. return (__builtin_mul_overflow(a, b, ret) == 0);
  3002. }
  3003. #define SDL_size_mul_check_overflow(a, b, ret) SDL_size_mul_check_overflow_builtin(a, b, ret)
  3004. #endif
  3005. #endif
  3006. /**
  3007. * Add two integers, checking for overflow.
  3008. *
  3009. * If `a + b` would overflow, return -1.
  3010. *
  3011. * Otherwise store `a + b` via ret and return 0.
  3012. *
  3013. * \param a the first addend.
  3014. * \param b the second addend.
  3015. * \param ret on non-overflow output, stores the addition result. May not be
  3016. * NULL.
  3017. * \returns SDL_FALSE on overflow, SDL_TRUE if result is added without
  3018. * overflow.
  3019. *
  3020. * \threadsafety It is safe to call this function from any thread.
  3021. *
  3022. * \since This function is available since SDL 3.0.0.
  3023. */
  3024. SDL_FORCE_INLINE SDL_bool SDL_size_add_check_overflow(size_t a, size_t b, size_t *ret)
  3025. {
  3026. if (b > SDL_SIZE_MAX - a) {
  3027. return SDL_FALSE;
  3028. }
  3029. *ret = a + b;
  3030. return SDL_TRUE;
  3031. }
  3032. #ifndef SDL_WIKI_DOCUMENTATION_SECTION
  3033. #if SDL_HAS_BUILTIN(__builtin_add_overflow)
  3034. /* This needs to be wrapped in an inline rather than being a direct #define,
  3035. * the same as the call to __builtin_mul_overflow() above. */
  3036. SDL_FORCE_INLINE SDL_bool SDL_size_add_check_overflow_builtin(size_t a, size_t b, size_t *ret)
  3037. {
  3038. return (__builtin_add_overflow(a, b, ret) == 0);
  3039. }
  3040. #define SDL_size_add_check_overflow(a, b, ret) SDL_size_add_check_overflow_builtin(a, b, ret)
  3041. #endif
  3042. #endif
  3043. /* This is a generic function pointer which should be cast to the type you expect */
  3044. #ifdef SDL_FUNCTION_POINTER_IS_VOID_POINTER
  3045. typedef void *SDL_FunctionPointer;
  3046. #else
  3047. typedef void (*SDL_FunctionPointer)(void);
  3048. #endif
  3049. /* Ends C function definitions when using C++ */
  3050. #ifdef __cplusplus
  3051. }
  3052. #endif
  3053. #include <SDL3/SDL_close_code.h>
  3054. #endif /* SDL_stdinc_h_ */