SDL_stdinc.h 105 KB

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