sdl3_sys/generated/stdinc.rs
1//! SDL provides its own implementation of some of the most important C runtime
2//! functions.
3//!
4//! Using these functions allows an app to have access to common C
5//! functionality without depending on a specific C runtime (or a C runtime at
6//! all). More importantly, the SDL implementations work identically across
7//! platforms, so apps can avoid surprises like snprintf() behaving differently
8//! between Windows and Linux builds, or itoa() only existing on some
9//! platforms.
10//!
11//! For many of the most common functions, like [`SDL_memcpy`], SDL might just call
12//! through to the usual C runtime behind the scenes, if it makes sense to do
13//! so (if it's faster and always available/reliable on a given platform),
14//! reducing library size and offering the most optimized option.
15//!
16//! SDL also offers other C-runtime-adjacent functionality in this header that
17//! either isn't, strictly speaking, part of any C runtime standards, like
18//! [`SDL_crc32()`] and [`SDL_reinterpret_cast`], etc. It also offers a few better
19//! options, like [`SDL_strlcpy()`], which functions as a safer form of strcpy().
20
21apply_cfg!(#[cfg(doc)] => {
22 /// Don't let SDL use "long long" C types.
23 ///
24 /// SDL will define this if it believes the compiler doesn't understand the
25 /// "long long" syntax for C datatypes. This can happen on older compilers.
26 ///
27 /// If _your_ compiler doesn't support "long long" but SDL doesn't know it, it
28 /// is safe to define this yourself to build against the SDL headers.
29 ///
30 /// If this is defined, it will remove access to some C runtime support
31 /// functions, like [`SDL_ulltoa`] and [`SDL_strtoll`] that refer to this datatype
32 /// explicitly. The rest of SDL will still be available.
33 ///
34 /// SDL's own source code cannot be built with a compiler that has this
35 /// defined, for various technical reasons.
36 pub const SDL_NOLONGLONG: ::core::primitive::i32 = 1;
37
38});
39
40apply_cfg!(#[cfg(not(doc))] => {
41});
42
43apply_cfg!(#[cfg(doc)] => {
44 /// The largest value that a `size_t` can hold for the target platform.
45 ///
46 /// `size_t` is generally the same size as a pointer in modern times, but this
47 /// can get weird on very old and very esoteric machines. For example, on a
48 /// 16-bit Intel 286, you might have a 32-bit "far" pointer (16-bit segment
49 /// plus 16-bit offset), but `size_t` is 16 bits, because it can only deal with
50 /// the offset into an individual segment.
51 ///
52 /// In modern times, it's generally expected to cover an entire linear address
53 /// space. But be careful!
54 ///
55 /// ## Availability
56 /// This macro is available since SDL 3.2.0.
57 pub const SDL_SIZE_MAX: ::core::primitive::usize = ::core::primitive::usize::MAX;
58
59});
60
61apply_cfg!(#[cfg(not(doc))] => {
62 pub const SDL_SIZE_MAX: ::core::primitive::usize = ::core::primitive::usize::MAX;
63
64});
65
66apply_cfg!(#[cfg(doc)] => {
67});
68
69apply_cfg!(#[cfg(not(doc))] => {
70});
71
72apply_cfg!(#[cfg(doc)] => {
73});
74
75apply_cfg!(#[cfg(not(doc))] => {
76});
77
78apply_cfg!(#[cfg(doc)] => {
79});
80
81apply_cfg!(#[cfg(not(doc))] => {
82});
83
84/// A signed 8-bit integer type.
85///
86/// ## Availability
87/// This macro is available since SDL 3.2.0.
88pub type Sint8 = ::core::primitive::i8;
89
90pub const SDL_MAX_SINT8: Sint8 = (0x7f as Sint8);
91
92pub const SDL_MIN_SINT8: Sint8 = ((-128_i32) as Sint8);
93
94/// An unsigned 8-bit integer type.
95///
96/// ## Availability
97/// This macro is available since SDL 3.2.0.
98pub type Uint8 = ::core::primitive::u8;
99
100pub const SDL_MAX_UINT8: Uint8 = (0xff as Uint8);
101
102pub const SDL_MIN_UINT8: Uint8 = (0x00 as Uint8);
103
104/// A signed 16-bit integer type.
105///
106/// ## Availability
107/// This macro is available since SDL 3.2.0.
108pub type Sint16 = ::core::primitive::i16;
109
110pub const SDL_MAX_SINT16: Sint16 = (0x7fff as Sint16);
111
112pub const SDL_MIN_SINT16: Sint16 = ((-32768_i32) as Sint16);
113
114/// An unsigned 16-bit integer type.
115///
116/// ## Availability
117/// This macro is available since SDL 3.2.0.
118pub type Uint16 = ::core::primitive::u16;
119
120pub const SDL_MAX_UINT16: Uint16 = (0xffff as Uint16);
121
122pub const SDL_MIN_UINT16: Uint16 = (0x0000 as Uint16);
123
124/// A signed 32-bit integer type.
125///
126/// ## Availability
127/// This macro is available since SDL 3.2.0.
128pub type Sint32 = ::core::primitive::i32;
129
130pub const SDL_MAX_SINT32: Sint32 = (0x7fffffff as Sint32);
131
132pub const SDL_MIN_SINT32: Sint32 = ((-2147483648_i32) as Sint32);
133
134/// An unsigned 32-bit integer type.
135///
136/// ## Availability
137/// This macro is available since SDL 3.2.0.
138pub type Uint32 = ::core::primitive::u32;
139
140pub const SDL_MAX_UINT32: Uint32 = (0xffffffff as Uint32);
141
142pub const SDL_MIN_UINT32: Uint32 = (0x00000000 as Uint32);
143
144/// A signed 64-bit integer type.
145///
146/// ## Availability
147/// This macro is available since SDL 3.2.0.
148///
149/// ## See also
150/// - SDL_SINT64_C
151pub type Sint64 = ::core::primitive::i64;
152
153pub const SDL_MAX_SINT64: ::core::primitive::i64 = 9223372036854775807_i64;
154
155pub const SDL_MIN_SINT64: ::core::primitive::i64 = -9223372036854775808_i64;
156
157/// An unsigned 64-bit integer type.
158///
159/// ## Availability
160/// This macro is available since SDL 3.2.0.
161///
162/// ## See also
163/// - SDL_UINT64_C
164pub type Uint64 = ::core::primitive::u64;
165
166pub const SDL_MAX_UINT64: ::core::primitive::u64 = 18446744073709551615_u64;
167
168pub const SDL_MIN_UINT64: ::core::primitive::u64 = 0_u64;
169
170/// SDL times are signed, 64-bit integers representing nanoseconds since the
171/// Unix epoch (Jan 1, 1970).
172///
173/// They can be converted between POSIX time_t values with [`SDL_NS_TO_SECONDS()`]
174/// and [`SDL_SECONDS_TO_NS()`], and between Windows FILETIME values with
175/// [`SDL_TimeToWindows()`] and [`SDL_TimeFromWindows()`].
176///
177/// ## Availability
178/// This datatype is available since SDL 3.2.0.
179///
180/// ## See also
181/// - [`SDL_MAX_SINT64`]
182/// - [`SDL_MIN_SINT64`]
183pub type SDL_Time = Sint64;
184
185pub const SDL_MAX_TIME: ::core::primitive::i64 = SDL_MAX_SINT64;
186
187pub const SDL_MIN_TIME: ::core::primitive::i64 = SDL_MIN_SINT64;
188
189pub const SDL_FLT_EPSILON: ::core::ffi::c_float = ::core::primitive::f32::EPSILON;
190
191apply_cfg!(#[cfg(doc)] => {
192 /// A printf-formatting string for an Sint64 value.
193 ///
194 /// Use it like this:
195 ///
196 /// ```c
197 /// SDL_Log("There are %" SDL_PRIs64 " bottles of beer on the wall.", bottles);
198 /// ```
199 ///
200 /// ## Availability
201 /// This macro is available since SDL 3.2.0.
202 pub const SDL_PRIs64: *const ::core::ffi::c_char = c"lld".as_ptr();
203
204 /// A printf-formatting string for a Uint64 value.
205 ///
206 /// Use it like this:
207 ///
208 /// ```c
209 /// SDL_Log("There are %" SDL_PRIu64 " bottles of beer on the wall.", bottles);
210 /// ```
211 ///
212 /// ## Availability
213 /// This macro is available since SDL 3.2.0.
214 pub const SDL_PRIu64: *const ::core::ffi::c_char = c"llu".as_ptr();
215
216 /// A printf-formatting string for a Uint64 value as lower-case hexadecimal.
217 ///
218 /// Use it like this:
219 ///
220 /// ```c
221 /// SDL_Log("There are %" SDL_PRIx64 " bottles of beer on the wall.", bottles);
222 /// ```
223 ///
224 /// ## Availability
225 /// This macro is available since SDL 3.2.0.
226 pub const SDL_PRIx64: *const ::core::ffi::c_char = c"llx".as_ptr();
227
228 /// A printf-formatting string for a Uint64 value as upper-case hexadecimal.
229 ///
230 /// Use it like this:
231 ///
232 /// ```c
233 /// SDL_Log("There are %" SDL_PRIX64 " bottles of beer on the wall.", bottles);
234 /// ```
235 ///
236 /// ## Availability
237 /// This macro is available since SDL 3.2.0.
238 pub const SDL_PRIX64: *const ::core::ffi::c_char = c"llX".as_ptr();
239
240 /// A printf-formatting string for an Sint32 value.
241 ///
242 /// Use it like this:
243 ///
244 /// ```c
245 /// SDL_Log("There are %" SDL_PRIs32 " bottles of beer on the wall.", bottles);
246 /// ```
247 ///
248 /// ## Availability
249 /// This macro is available since SDL 3.2.0.
250 pub const SDL_PRIs32: *const ::core::ffi::c_char = c"d".as_ptr();
251
252 /// A printf-formatting string for a Uint32 value.
253 ///
254 /// Use it like this:
255 ///
256 /// ```c
257 /// SDL_Log("There are %" SDL_PRIu32 " bottles of beer on the wall.", bottles);
258 /// ```
259 ///
260 /// ## Availability
261 /// This macro is available since SDL 3.2.0.
262 pub const SDL_PRIu32: *const ::core::ffi::c_char = c"u".as_ptr();
263
264 /// A printf-formatting string for a Uint32 value as lower-case hexadecimal.
265 ///
266 /// Use it like this:
267 ///
268 /// ```c
269 /// SDL_Log("There are %" SDL_PRIx32 " bottles of beer on the wall.", bottles);
270 /// ```
271 ///
272 /// ## Availability
273 /// This macro is available since SDL 3.2.0.
274 pub const SDL_PRIx32: *const ::core::ffi::c_char = c"x".as_ptr();
275
276 /// A printf-formatting string for a Uint32 value as upper-case hexadecimal.
277 ///
278 /// Use it like this:
279 ///
280 /// ```c
281 /// SDL_Log("There are %" SDL_PRIX32 " bottles of beer on the wall.", bottles);
282 /// ```
283 ///
284 /// ## Availability
285 /// This macro is available since SDL 3.2.0.
286 pub const SDL_PRIX32: *const ::core::ffi::c_char = c"X".as_ptr();
287
288 /// A printf-formatting string prefix for a `long long` value.
289 ///
290 /// This is just the prefix! You probably actually want [`SDL_PRILLd`], [`SDL_PRILLu`],
291 /// [`SDL_PRILLx`], or [`SDL_PRILLX`] instead.
292 ///
293 /// Use it like this:
294 ///
295 /// ```c
296 /// SDL_Log("There are %" SDL_PRILL_PREFIX "d bottles of beer on the wall.", bottles);
297 /// ```
298 ///
299 /// ## Availability
300 /// This macro is available since SDL 3.2.0.
301 pub const SDL_PRILL_PREFIX: *const ::core::ffi::c_char = c"ll".as_ptr();
302
303 /// A printf-formatting string for a `long long` value.
304 ///
305 /// Use it like this:
306 ///
307 /// ```c
308 /// SDL_Log("There are %" SDL_PRILLd " bottles of beer on the wall.", bottles);
309 /// ```
310 ///
311 /// ## Availability
312 /// This macro is available since SDL 3.2.0.
313 pub const SDL_PRILLd: *const ::core::ffi::c_char = c"lld".as_ptr();
314
315 /// A printf-formatting string for a `unsigned long long` value.
316 ///
317 /// Use it like this:
318 ///
319 /// ```c
320 /// SDL_Log("There are %" SDL_PRILLu " bottles of beer on the wall.", bottles);
321 /// ```
322 ///
323 /// ## Availability
324 /// This macro is available since SDL 3.2.0.
325 pub const SDL_PRILLu: *const ::core::ffi::c_char = c"llu".as_ptr();
326
327 /// A printf-formatting string for an `unsigned long long` value as lower-case
328 /// hexadecimal.
329 ///
330 /// Use it like this:
331 ///
332 /// ```c
333 /// SDL_Log("There are %" SDL_PRILLx " bottles of beer on the wall.", bottles);
334 /// ```
335 ///
336 /// ## Availability
337 /// This macro is available since SDL 3.2.0.
338 pub const SDL_PRILLx: *const ::core::ffi::c_char = c"llx".as_ptr();
339
340 /// A printf-formatting string for an `unsigned long long` value as upper-case
341 /// hexadecimal.
342 ///
343 /// Use it like this:
344 ///
345 /// ```c
346 /// SDL_Log("There are %" SDL_PRILLX " bottles of beer on the wall.", bottles);
347 /// ```
348 ///
349 /// ## Availability
350 /// This macro is available since SDL 3.2.0.
351 pub const SDL_PRILLX: *const ::core::ffi::c_char = c"llX".as_ptr();
352
353});
354
355apply_cfg!(#[cfg(any(doc, windows))] => {
356 #[cfg(not(doc))]
357 pub const SDL_PRIs64: *const ::core::ffi::c_char = c"I64d".as_ptr();
358
359});
360
361apply_cfg!(#[cfg(not(any(doc, windows)))] => {
362 apply_cfg!(#[cfg(all(not(any(doc, target_vendor = "apple")), not(target_os = "emscripten"), all(not(windows), target_pointer_width = "64")))] => {
363 #[cfg(not(doc))]
364 pub const SDL_PRIs64: *const ::core::ffi::c_char = c"ld".as_ptr();
365
366 });
367
368 apply_cfg!(#[cfg(not(all(not(any(doc, target_vendor = "apple")), not(target_os = "emscripten"), all(not(windows), target_pointer_width = "64"))))] => {
369 #[cfg(not(doc))]
370 pub const SDL_PRIs64: *const ::core::ffi::c_char = c"lld".as_ptr();
371
372 });
373
374});
375
376apply_cfg!(#[cfg(any(doc, windows))] => {
377 #[cfg(not(doc))]
378 pub const SDL_PRIu64: *const ::core::ffi::c_char = c"I64u".as_ptr();
379
380});
381
382apply_cfg!(#[cfg(not(any(doc, windows)))] => {
383 apply_cfg!(#[cfg(all(not(any(doc, target_vendor = "apple")), not(target_os = "emscripten"), all(not(windows), target_pointer_width = "64")))] => {
384 #[cfg(not(doc))]
385 pub const SDL_PRIu64: *const ::core::ffi::c_char = c"lu".as_ptr();
386
387 });
388
389 apply_cfg!(#[cfg(not(all(not(any(doc, target_vendor = "apple")), not(target_os = "emscripten"), all(not(windows), target_pointer_width = "64"))))] => {
390 #[cfg(not(doc))]
391 pub const SDL_PRIu64: *const ::core::ffi::c_char = c"llu".as_ptr();
392
393 });
394
395});
396
397apply_cfg!(#[cfg(any(doc, windows))] => {
398 #[cfg(not(doc))]
399 pub const SDL_PRIx64: *const ::core::ffi::c_char = c"I64x".as_ptr();
400
401});
402
403apply_cfg!(#[cfg(not(any(doc, windows)))] => {
404 apply_cfg!(#[cfg(all(not(any(doc, target_vendor = "apple")), all(not(windows), target_pointer_width = "64")))] => {
405 #[cfg(not(doc))]
406 pub const SDL_PRIx64: *const ::core::ffi::c_char = c"lx".as_ptr();
407
408 });
409
410 apply_cfg!(#[cfg(not(all(not(any(doc, target_vendor = "apple")), all(not(windows), target_pointer_width = "64"))))] => {
411 #[cfg(not(doc))]
412 pub const SDL_PRIx64: *const ::core::ffi::c_char = c"llx".as_ptr();
413
414 });
415
416});
417
418apply_cfg!(#[cfg(any(doc, windows))] => {
419 #[cfg(not(doc))]
420 pub const SDL_PRIX64: *const ::core::ffi::c_char = c"I64X".as_ptr();
421
422});
423
424apply_cfg!(#[cfg(not(any(doc, windows)))] => {
425 apply_cfg!(#[cfg(all(not(any(doc, target_vendor = "apple")), all(not(windows), target_pointer_width = "64")))] => {
426 #[cfg(not(doc))]
427 pub const SDL_PRIX64: *const ::core::ffi::c_char = c"lX".as_ptr();
428
429 });
430
431 apply_cfg!(#[cfg(not(all(not(any(doc, target_vendor = "apple")), all(not(windows), target_pointer_width = "64"))))] => {
432 #[cfg(not(doc))]
433 pub const SDL_PRIX64: *const ::core::ffi::c_char = c"llX".as_ptr();
434
435 });
436
437});
438
439#[cfg(not(doc))]
440pub const SDL_PRIs32: *const ::core::ffi::c_char = c"d".as_ptr();
441
442#[cfg(not(doc))]
443pub const SDL_PRIu32: *const ::core::ffi::c_char = c"u".as_ptr();
444
445#[cfg(not(doc))]
446pub const SDL_PRIx32: *const ::core::ffi::c_char = c"x".as_ptr();
447
448#[cfg(not(doc))]
449pub const SDL_PRIX32: *const ::core::ffi::c_char = c"X".as_ptr();
450
451apply_cfg!(#[cfg(any(doc, windows))] => {
452 const _: () = ::core::assert!((::core::mem::size_of::<::core::ffi::c_longlong>() == 8_usize));
453
454 #[cfg(not(doc))]
455 pub const SDL_PRILL_PREFIX: *const ::core::ffi::c_char = c"I64".as_ptr();
456
457 #[cfg(not(doc))]
458 pub const SDL_PRILLd: *const ::core::ffi::c_char = c"I64d".as_ptr();
459
460 #[cfg(not(doc))]
461 pub const SDL_PRILLu: *const ::core::ffi::c_char = c"I64u".as_ptr();
462
463 #[cfg(not(doc))]
464 pub const SDL_PRILLx: *const ::core::ffi::c_char = c"I64x".as_ptr();
465
466 #[cfg(not(doc))]
467 pub const SDL_PRILLX: *const ::core::ffi::c_char = c"I64X".as_ptr();
468
469});
470
471apply_cfg!(#[cfg(not(any(doc, windows)))] => {
472 #[cfg(not(doc))]
473 pub const SDL_PRILL_PREFIX: *const ::core::ffi::c_char = c"ll".as_ptr();
474
475 #[cfg(not(doc))]
476 pub const SDL_PRILLd: *const ::core::ffi::c_char = c"lld".as_ptr();
477
478 #[cfg(not(doc))]
479 pub const SDL_PRILLu: *const ::core::ffi::c_char = c"llu".as_ptr();
480
481 #[cfg(not(doc))]
482 pub const SDL_PRILLx: *const ::core::ffi::c_char = c"llx".as_ptr();
483
484 #[cfg(not(doc))]
485 pub const SDL_PRILLX: *const ::core::ffi::c_char = c"llX".as_ptr();
486
487});
488
489apply_cfg!(#[cfg(doc)] => {
490});
491
492apply_cfg!(#[cfg(not(doc))] => {
493});
494
495const _: () = ::core::assert!((::core::mem::size_of::<::core::primitive::bool>() == 1_usize));
496
497const _: () = ::core::assert!((::core::mem::size_of::<Uint8>() == 1_usize));
498
499const _: () = ::core::assert!((::core::mem::size_of::<Sint8>() == 1_usize));
500
501const _: () = ::core::assert!((::core::mem::size_of::<Uint16>() == 2_usize));
502
503const _: () = ::core::assert!((::core::mem::size_of::<Sint16>() == 2_usize));
504
505const _: () = ::core::assert!((::core::mem::size_of::<Uint32>() == 4_usize));
506
507const _: () = ::core::assert!((::core::mem::size_of::<Sint32>() == 4_usize));
508
509const _: () = ::core::assert!((::core::mem::size_of::<Uint64>() == 8_usize));
510
511const _: () = ::core::assert!((::core::mem::size_of::<Sint64>() == 8_usize));
512
513const _: () = ::core::assert!(
514 (::core::mem::size_of::<Uint64>() <= ::core::mem::size_of::<::core::ffi::c_ulonglong>())
515);
516
517const _: () = ::core::assert!(
518 (::core::mem::size_of::<::core::primitive::usize>()
519 <= ::core::mem::size_of::<::core::ffi::c_ulonglong>())
520);
521
522/// Define a four character code as a Uint32.
523///
524/// ## Parameters
525/// - `A`: the first ASCII character.
526/// - `B`: the second ASCII character.
527/// - `C`: the third ASCII character.
528/// - `D`: the fourth ASCII character.
529///
530/// ## Return value
531/// Returns the four characters converted into a Uint32, one character
532/// per-byte.
533///
534/// ## Thread safety
535/// It is safe to call this macro from any thread.
536///
537/// ## Availability
538/// This macro is available since SDL 3.2.0.
539#[inline(always)]
540pub const fn SDL_FOURCC(A: Uint8, B: Uint8, C: Uint8, D: Uint8) -> Uint32 {
541 (((((A as Uint32) << 0) | ((B as Uint32) << 8)) | ((C as Uint32) << 16))
542 | ((D as Uint32) << 24))
543}
544
545#[doc(hidden)]
546#[repr(C)]
547#[cfg_attr(feature = "debug-impls", derive(Debug))]
548pub struct SDL_alignment_test {
549 pub a: Uint8,
550 pub b: *mut ::core::ffi::c_void,
551}
552
553impl ::core::default::Default for SDL_alignment_test {
554 /// Initialize all fields to zero
555 #[inline(always)]
556 fn default() -> Self {
557 unsafe { ::core::mem::MaybeUninit::<Self>::zeroed().assume_init() }
558 }
559}
560
561const _: () = ::core::assert!(
562 (::core::mem::size_of::<SDL_alignment_test>()
563 == (2 * ::core::mem::size_of::<*mut ::core::ffi::c_void>()))
564);
565
566const _: () = ::core::assert!((!(0 as ::core::ffi::c_int) == (-1_i32 as ::core::ffi::c_int)));
567
568apply_cfg!(#[cfg(all(not(any(doc, target_os = "horizon")), not(any(doc, target_os = "vita"))))] => {
569 #[doc(hidden)]
570 /// ## Known values (`sdl3-sys`)
571 /// | Associated constant | Global constant | Description |
572 /// | ------------------- | --------------- | ----------- |
573 /// | [`DUMMY_ENUM_VALUE`](SDL_DUMMY_ENUM::DUMMY_ENUM_VALUE) | [`DUMMY_ENUM_VALUE`] | |
574 #[repr(transparent)]
575 #[derive(Clone, Copy)]
576 #[derive(Default)]
577 #[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
578 pub struct SDL_DUMMY_ENUM(pub ::core::ffi::c_int);
579
580 impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_DUMMY_ENUM {
581 #[inline(always)]
582 fn eq(&self, other: &::core::ffi::c_int) -> bool {
583 &self.0 == other
584 }
585 }
586
587 impl ::core::cmp::PartialEq<SDL_DUMMY_ENUM> for ::core::ffi::c_int {
588 #[inline(always)]
589 fn eq(&self, other: &SDL_DUMMY_ENUM) -> bool {
590 self == &other.0
591 }
592 }
593
594 impl From<SDL_DUMMY_ENUM> for ::core::ffi::c_int {
595 #[inline(always)]
596 fn from(value: SDL_DUMMY_ENUM) -> Self {
597 value.0
598 }
599 }
600
601 #[cfg(feature = "debug-impls")]
602 impl ::core::fmt::Debug for SDL_DUMMY_ENUM {
603 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
604 #[allow(unreachable_patterns)]
605 f.write_str(match *self {
606 Self::DUMMY_ENUM_VALUE => "DUMMY_ENUM_VALUE",
607
608 _ => return write!(f, "SDL_DUMMY_ENUM({})", self.0),
609 })
610 }
611 }
612
613 impl SDL_DUMMY_ENUM {
614 pub const DUMMY_ENUM_VALUE: Self = Self((0 as ::core::ffi::c_int));
615 }
616
617 #[doc(hidden)]
618 pub const DUMMY_ENUM_VALUE: SDL_DUMMY_ENUM = SDL_DUMMY_ENUM::DUMMY_ENUM_VALUE;
619
620 const _: () = ::core::assert!((::core::mem::size_of::<SDL_DUMMY_ENUM>() == ::core::mem::size_of::<::core::ffi::c_int>()));
621
622});
623
624/// A macro to initialize an SDL interface.
625///
626/// This macro will initialize an SDL interface structure and should be called
627/// before you fill out the fields with your implementation.
628///
629/// You can use it like this:
630///
631/// ```c
632/// SDL_IOStreamInterface iface;
633///
634/// SDL_INIT_INTERFACE(&iface);
635///
636/// // Fill in the interface function pointers with your implementation
637/// iface.seek = ...
638///
639/// stream = SDL_OpenIO(&iface, NULL);
640/// ```
641///
642/// If you are using designated initializers, you can use the size of the
643/// interface as the version, e.g.
644///
645/// ```c
646/// SDL_IOStreamInterface iface = {
647/// .version = sizeof(iface),
648/// .seek = ...
649/// };
650/// stream = SDL_OpenIO(&iface, NULL);
651/// ```
652///
653/// ## Thread safety
654/// It is safe to call this macro from any thread.
655///
656/// ## Availability
657/// This macro is available since SDL 3.2.0.
658///
659/// ## See also
660/// - [`SDL_IOStreamInterface`]
661/// - [`SDL_StorageInterface`]
662/// - [`SDL_VirtualJoystickDesc`]
663///
664/// ## Safety (`sdl3-sys`)
665/// - `iface` must point to memory that is valid for writing the type `T`.
666/// - The type `T` must be a `repr(C)` struct.
667/// - The first field of the struct must be of type `u32`. It will be set to
668/// the size of the struct in bytes.
669/// - The rest of the struct will be initialized as all zero bytes.
670#[inline(always)]
671pub unsafe fn SDL_INIT_INTERFACE<T>(iface: *mut T) {
672 const { ::core::assert!(::core::mem::size_of::<T>() <= ::core::primitive::u32::MAX as usize) };
673 unsafe {
674 iface.write_bytes(0, 1);
675 iface
676 .cast::<Uint32>()
677 .write(::core::mem::size_of::<T>() as Uint32);
678 }
679}
680
681apply_cfg!(#[cfg(doc)] => {
682});
683
684apply_cfg!(#[cfg(not(doc))] => {
685});
686
687unsafe extern "C" {
688 /// Allocate uninitialized memory.
689 ///
690 /// The allocated memory returned by this function must be freed with
691 /// [`SDL_free()`].
692 ///
693 /// If `size` is 0, it will be set to 1.
694 ///
695 /// If the allocation is successful, the returned pointer is guaranteed to be
696 /// aligned to either the *fundamental alignment* (`alignof(max_align_t)` in
697 /// C11 and later) or `2 * sizeof(void *)`, whichever is smaller. Use
698 /// [`SDL_aligned_alloc()`] if you need to allocate memory aligned to an alignment
699 /// greater than this guarantee.
700 ///
701 /// ## Parameters
702 /// - `size`: the size to allocate.
703 ///
704 /// ## Return value
705 /// Returns a pointer to the allocated memory, or NULL if allocation failed.
706 ///
707 /// ## Thread safety
708 /// It is safe to call this function from any thread.
709 ///
710 /// ## Availability
711 /// This function is available since SDL 3.2.0.
712 ///
713 /// ## See also
714 /// - [`SDL_free`]
715 /// - [`SDL_calloc`]
716 /// - [`SDL_realloc`]
717 /// - [`SDL_aligned_alloc`]
718 pub fn SDL_malloc(size: ::core::primitive::usize) -> *mut ::core::ffi::c_void;
719}
720
721unsafe extern "C" {
722 /// Allocate a zero-initialized array.
723 ///
724 /// The memory returned by this function must be freed with [`SDL_free()`].
725 ///
726 /// If either of `nmemb` or `size` is 0, they will both be set to 1.
727 ///
728 /// If the allocation is successful, the returned pointer is guaranteed to be
729 /// aligned to either the *fundamental alignment* (`alignof(max_align_t)` in
730 /// C11 and later) or `2 * sizeof(void *)`, whichever is smaller.
731 ///
732 /// ## Parameters
733 /// - `nmemb`: the number of elements in the array.
734 /// - `size`: the size of each element of the array.
735 ///
736 /// ## Return value
737 /// Returns a pointer to the allocated array, or NULL if allocation failed.
738 ///
739 /// ## Thread safety
740 /// It is safe to call this function from any thread.
741 ///
742 /// ## Availability
743 /// This function is available since SDL 3.2.0.
744 ///
745 /// ## See also
746 /// - [`SDL_free`]
747 /// - [`SDL_malloc`]
748 /// - [`SDL_realloc`]
749 pub fn SDL_calloc(
750 nmemb: ::core::primitive::usize,
751 size: ::core::primitive::usize,
752 ) -> *mut ::core::ffi::c_void;
753}
754
755unsafe extern "C" {
756 /// Change the size of allocated memory.
757 ///
758 /// The memory returned by this function must be freed with [`SDL_free()`].
759 ///
760 /// If `size` is 0, it will be set to 1. Note that this is unlike some other C
761 /// runtime `realloc` implementations, which may treat `realloc(mem, 0)` the
762 /// same way as `free(mem)`.
763 ///
764 /// If `mem` is NULL, the behavior of this function is equivalent to
765 /// [`SDL_malloc()`]. Otherwise, the function can have one of three possible
766 /// outcomes:
767 ///
768 /// - If it returns the same pointer as `mem`, it means that `mem` was resized
769 /// in place without freeing.
770 /// - If it returns a different non-NULL pointer, it means that `mem` was freed
771 /// and cannot be dereferenced anymore.
772 /// - If it returns NULL (indicating failure), then `mem` will remain valid and
773 /// must still be freed with [`SDL_free()`].
774 ///
775 /// If the allocation is successfully resized, the returned pointer is
776 /// guaranteed to be aligned to either the *fundamental alignment*
777 /// (`alignof(max_align_t)` in C11 and later) or `2 * sizeof(void *)`,
778 /// whichever is smaller.
779 ///
780 /// ## Parameters
781 /// - `mem`: a pointer to allocated memory to reallocate, or NULL.
782 /// - `size`: the new size of the memory.
783 ///
784 /// ## Return value
785 /// Returns a pointer to the newly allocated memory, or NULL if allocation
786 /// failed.
787 ///
788 /// ## Thread safety
789 /// It is safe to call this function from any thread.
790 ///
791 /// ## Availability
792 /// This function is available since SDL 3.2.0.
793 ///
794 /// ## See also
795 /// - [`SDL_free`]
796 /// - [`SDL_malloc`]
797 /// - [`SDL_calloc`]
798 pub fn SDL_realloc(
799 mem: *mut ::core::ffi::c_void,
800 size: ::core::primitive::usize,
801 ) -> *mut ::core::ffi::c_void;
802}
803
804unsafe extern "C" {
805 /// Free allocated memory.
806 ///
807 /// The pointer is no longer valid after this call and cannot be dereferenced
808 /// anymore.
809 ///
810 /// If `mem` is NULL, this function does nothing.
811 ///
812 /// ## Parameters
813 /// - `mem`: a pointer to allocated memory, or NULL.
814 ///
815 /// ## Thread safety
816 /// It is safe to call this function from any thread.
817 ///
818 /// ## Availability
819 /// This function is available since SDL 3.2.0.
820 ///
821 /// ## See also
822 /// - [`SDL_malloc`]
823 /// - [`SDL_calloc`]
824 /// - [`SDL_realloc`]
825 pub fn SDL_free(mem: *mut ::core::ffi::c_void);
826}
827
828/// A callback used to implement [`SDL_malloc()`].
829///
830/// SDL will always ensure that the passed `size` is greater than 0.
831///
832/// ## Parameters
833/// - `size`: the size to allocate.
834///
835/// ## Return value
836/// Returns a pointer to the allocated memory, or NULL if allocation failed.
837///
838/// ## Thread safety
839/// It should be safe to call this callback from any thread.
840///
841/// ## Availability
842/// This datatype is available since SDL 3.2.0.
843///
844/// ## See also
845/// - [`SDL_malloc`]
846/// - [`SDL_GetOriginalMemoryFunctions`]
847/// - [`SDL_GetMemoryFunctions`]
848/// - [`SDL_SetMemoryFunctions`]
849pub type SDL_malloc_func = ::core::option::Option<
850 unsafe extern "C" fn(size: ::core::primitive::usize) -> *mut ::core::ffi::c_void,
851>;
852
853/// A callback used to implement [`SDL_calloc()`].
854///
855/// SDL will always ensure that the passed `nmemb` and `size` are both greater
856/// than 0.
857///
858/// ## Parameters
859/// - `nmemb`: the number of elements in the array.
860/// - `size`: the size of each element of the array.
861///
862/// ## Return value
863/// Returns a pointer to the allocated array, or NULL if allocation failed.
864///
865/// ## Thread safety
866/// It should be safe to call this callback from any thread.
867///
868/// ## Availability
869/// This datatype is available since SDL 3.2.0.
870///
871/// ## See also
872/// - [`SDL_calloc`]
873/// - [`SDL_GetOriginalMemoryFunctions`]
874/// - [`SDL_GetMemoryFunctions`]
875/// - [`SDL_SetMemoryFunctions`]
876pub type SDL_calloc_func = ::core::option::Option<
877 unsafe extern "C" fn(
878 nmemb: ::core::primitive::usize,
879 size: ::core::primitive::usize,
880 ) -> *mut ::core::ffi::c_void,
881>;
882
883/// A callback used to implement [`SDL_realloc()`].
884///
885/// SDL will always ensure that the passed `size` is greater than 0.
886///
887/// ## Parameters
888/// - `mem`: a pointer to allocated memory to reallocate, or NULL.
889/// - `size`: the new size of the memory.
890///
891/// ## Return value
892/// Returns a pointer to the newly allocated memory, or NULL if allocation
893/// failed.
894///
895/// ## Thread safety
896/// It should be safe to call this callback from any thread.
897///
898/// ## Availability
899/// This datatype is available since SDL 3.2.0.
900///
901/// ## See also
902/// - [`SDL_realloc`]
903/// - [`SDL_GetOriginalMemoryFunctions`]
904/// - [`SDL_GetMemoryFunctions`]
905/// - [`SDL_SetMemoryFunctions`]
906pub type SDL_realloc_func = ::core::option::Option<
907 unsafe extern "C" fn(
908 mem: *mut ::core::ffi::c_void,
909 size: ::core::primitive::usize,
910 ) -> *mut ::core::ffi::c_void,
911>;
912
913/// A callback used to implement [`SDL_free()`].
914///
915/// SDL will always ensure that the passed `mem` is a non-NULL pointer.
916///
917/// ## Parameters
918/// - `mem`: a pointer to allocated memory.
919///
920/// ## Thread safety
921/// It should be safe to call this callback from any thread.
922///
923/// ## Availability
924/// This datatype is available since SDL 3.2.0.
925///
926/// ## See also
927/// - [`SDL_free`]
928/// - [`SDL_GetOriginalMemoryFunctions`]
929/// - [`SDL_GetMemoryFunctions`]
930/// - [`SDL_SetMemoryFunctions`]
931pub type SDL_free_func =
932 ::core::option::Option<unsafe extern "C" fn(mem: *mut ::core::ffi::c_void)>;
933
934unsafe extern "C" {
935 /// Get the original set of SDL memory functions.
936 ///
937 /// This is what [`SDL_malloc`] and friends will use by default, if there has been
938 /// no call to [`SDL_SetMemoryFunctions`]. This is not necessarily using the C
939 /// runtime's `malloc` functions behind the scenes! Different platforms and
940 /// build configurations might do any number of unexpected things.
941 ///
942 /// ## Parameters
943 /// - `malloc_func`: filled with malloc function.
944 /// - `calloc_func`: filled with calloc function.
945 /// - `realloc_func`: filled with realloc function.
946 /// - `free_func`: filled with free function.
947 ///
948 /// ## Thread safety
949 /// It is safe to call this function from any thread.
950 ///
951 /// ## Availability
952 /// This function is available since SDL 3.2.0.
953 pub fn SDL_GetOriginalMemoryFunctions(
954 malloc_func: *mut SDL_malloc_func,
955 calloc_func: *mut SDL_calloc_func,
956 realloc_func: *mut SDL_realloc_func,
957 free_func: *mut SDL_free_func,
958 );
959}
960
961unsafe extern "C" {
962 /// Get the current set of SDL memory functions.
963 ///
964 /// ## Parameters
965 /// - `malloc_func`: filled with malloc function.
966 /// - `calloc_func`: filled with calloc function.
967 /// - `realloc_func`: filled with realloc function.
968 /// - `free_func`: filled with free function.
969 ///
970 /// ## Thread safety
971 /// This does not hold a lock, so do not call this in the
972 /// unlikely event of a background thread calling
973 /// [`SDL_SetMemoryFunctions`] simultaneously.
974 ///
975 /// ## Availability
976 /// This function is available since SDL 3.2.0.
977 ///
978 /// ## See also
979 /// - [`SDL_SetMemoryFunctions`]
980 /// - [`SDL_GetOriginalMemoryFunctions`]
981 pub fn SDL_GetMemoryFunctions(
982 malloc_func: *mut SDL_malloc_func,
983 calloc_func: *mut SDL_calloc_func,
984 realloc_func: *mut SDL_realloc_func,
985 free_func: *mut SDL_free_func,
986 );
987}
988
989unsafe extern "C" {
990 /// Replace SDL's memory allocation functions with a custom set.
991 ///
992 /// It is not safe to call this function once any allocations have been made,
993 /// as future calls to [`SDL_free`] will use the new allocator, even if they came
994 /// from an [`SDL_malloc`] made with the old one!
995 ///
996 /// If used, usually this needs to be the first call made into the SDL library,
997 /// if not the very first thing done at program startup time.
998 ///
999 /// ## Parameters
1000 /// - `malloc_func`: custom malloc function.
1001 /// - `calloc_func`: custom calloc function.
1002 /// - `realloc_func`: custom realloc function.
1003 /// - `free_func`: custom free function.
1004 ///
1005 /// ## Return value
1006 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1007 /// information.
1008 ///
1009 /// ## Thread safety
1010 /// It is safe to call this function from any thread, but one
1011 /// should not replace the memory functions once any allocations
1012 /// are made!
1013 ///
1014 /// ## Availability
1015 /// This function is available since SDL 3.2.0.
1016 ///
1017 /// ## See also
1018 /// - [`SDL_GetMemoryFunctions`]
1019 /// - [`SDL_GetOriginalMemoryFunctions`]
1020 pub fn SDL_SetMemoryFunctions(
1021 malloc_func: SDL_malloc_func,
1022 calloc_func: SDL_calloc_func,
1023 realloc_func: SDL_realloc_func,
1024 free_func: SDL_free_func,
1025 ) -> ::core::primitive::bool;
1026}
1027
1028unsafe extern "C" {
1029 /// Allocate memory aligned to a specific alignment.
1030 ///
1031 /// The memory returned by this function must be freed with [`SDL_aligned_free()`],
1032 /// _not_ [`SDL_free()`].
1033 ///
1034 /// If `alignment` is less than the size of `void *`, it will be increased to
1035 /// match that.
1036 ///
1037 /// The returned memory address will be a multiple of the alignment value, and
1038 /// the size of the memory allocated will be a multiple of the alignment value.
1039 ///
1040 /// ## Parameters
1041 /// - `alignment`: the alignment of the memory.
1042 /// - `size`: the size to allocate.
1043 ///
1044 /// ## Return value
1045 /// Returns a pointer to the aligned memory, or NULL if allocation failed.
1046 ///
1047 /// ## Thread safety
1048 /// It is safe to call this function from any thread.
1049 ///
1050 /// ## Availability
1051 /// This function is available since SDL 3.2.0.
1052 ///
1053 /// ## See also
1054 /// - [`SDL_aligned_free`]
1055 pub fn SDL_aligned_alloc(
1056 alignment: ::core::primitive::usize,
1057 size: ::core::primitive::usize,
1058 ) -> *mut ::core::ffi::c_void;
1059}
1060
1061unsafe extern "C" {
1062 /// Free memory allocated by [`SDL_aligned_alloc()`].
1063 ///
1064 /// The pointer is no longer valid after this call and cannot be dereferenced
1065 /// anymore.
1066 ///
1067 /// If `mem` is NULL, this function does nothing.
1068 ///
1069 /// ## Parameters
1070 /// - `mem`: a pointer previously returned by [`SDL_aligned_alloc()`], or NULL.
1071 ///
1072 /// ## Thread safety
1073 /// It is safe to call this function from any thread.
1074 ///
1075 /// ## Availability
1076 /// This function is available since SDL 3.2.0.
1077 ///
1078 /// ## See also
1079 /// - [`SDL_aligned_alloc`]
1080 pub fn SDL_aligned_free(mem: *mut ::core::ffi::c_void);
1081}
1082
1083unsafe extern "C" {
1084 /// Get the number of outstanding (unfreed) allocations.
1085 ///
1086 /// ## Return value
1087 /// Returns the number of allocations or -1 if allocation counting is
1088 /// disabled.
1089 ///
1090 /// ## Thread safety
1091 /// It is safe to call this function from any thread.
1092 ///
1093 /// ## Availability
1094 /// This function is available since SDL 3.2.0.
1095 pub safe fn SDL_GetNumAllocations() -> ::core::ffi::c_int;
1096}
1097
1098unsafe extern "C" {
1099 /// Get the process environment.
1100 ///
1101 /// This is initialized at application start and is not affected by setenv()
1102 /// and unsetenv() calls after that point. Use [`SDL_SetEnvironmentVariable()`] and
1103 /// [`SDL_UnsetEnvironmentVariable()`] if you want to modify this environment, or
1104 /// [`SDL_setenv_unsafe()`] or [`SDL_unsetenv_unsafe()`] if you want changes to persist
1105 /// in the C runtime environment after [`SDL_Quit()`].
1106 ///
1107 /// ## Return value
1108 /// Returns a pointer to the environment for the process or NULL on failure;
1109 /// call [`SDL_GetError()`] for more information.
1110 ///
1111 /// ## Thread safety
1112 /// It is safe to call this function from any thread.
1113 ///
1114 /// ## Availability
1115 /// This function is available since SDL 3.2.0.
1116 ///
1117 /// ## See also
1118 /// - [`SDL_GetEnvironmentVariable`]
1119 /// - [`SDL_GetEnvironmentVariables`]
1120 /// - [`SDL_SetEnvironmentVariable`]
1121 /// - [`SDL_UnsetEnvironmentVariable`]
1122 pub fn SDL_GetEnvironment() -> *mut SDL_Environment;
1123}
1124
1125unsafe extern "C" {
1126 /// Create a set of environment variables
1127 ///
1128 /// ## Parameters
1129 /// - `populated`: true to initialize it from the C runtime environment,
1130 /// false to create an empty environment.
1131 ///
1132 /// ## Return value
1133 /// Returns a pointer to the new environment or NULL on failure; call
1134 /// [`SDL_GetError()`] for more information.
1135 ///
1136 /// ## Thread safety
1137 /// If `populated` is false, it is safe to call this function
1138 /// from any thread, otherwise it is safe if no other threads are
1139 /// calling setenv() or unsetenv()
1140 ///
1141 /// ## Availability
1142 /// This function is available since SDL 3.2.0.
1143 ///
1144 /// ## See also
1145 /// - [`SDL_GetEnvironmentVariable`]
1146 /// - [`SDL_GetEnvironmentVariables`]
1147 /// - [`SDL_SetEnvironmentVariable`]
1148 /// - [`SDL_UnsetEnvironmentVariable`]
1149 /// - [`SDL_DestroyEnvironment`]
1150 pub fn SDL_CreateEnvironment(populated: ::core::primitive::bool) -> *mut SDL_Environment;
1151}
1152
1153unsafe extern "C" {
1154 /// Get the value of a variable in the environment.
1155 ///
1156 /// ## Parameters
1157 /// - `env`: the environment to query.
1158 /// - `name`: the name of the variable to get.
1159 ///
1160 /// ## Return value
1161 /// Returns a pointer to the value of the variable or NULL if it can't be
1162 /// found.
1163 ///
1164 /// ## Thread safety
1165 /// It is safe to call this function from any thread.
1166 ///
1167 /// ## Availability
1168 /// This function is available since SDL 3.2.0.
1169 ///
1170 /// ## See also
1171 /// - [`SDL_GetEnvironment`]
1172 /// - [`SDL_CreateEnvironment`]
1173 /// - [`SDL_GetEnvironmentVariables`]
1174 /// - [`SDL_SetEnvironmentVariable`]
1175 /// - [`SDL_UnsetEnvironmentVariable`]
1176 pub fn SDL_GetEnvironmentVariable(
1177 env: *mut SDL_Environment,
1178 name: *const ::core::ffi::c_char,
1179 ) -> *const ::core::ffi::c_char;
1180}
1181
1182unsafe extern "C" {
1183 /// Get all variables in the environment.
1184 ///
1185 /// ## Parameters
1186 /// - `env`: the environment to query.
1187 ///
1188 /// ## Return value
1189 /// Returns a NULL terminated array of pointers to environment variables in
1190 /// the form "variable=value" or NULL on failure; call [`SDL_GetError()`]
1191 /// for more information. This is a single allocation that should be
1192 /// freed with [`SDL_free()`] when it is no longer needed.
1193 ///
1194 /// ## Thread safety
1195 /// It is safe to call this function from any thread.
1196 ///
1197 /// ## Availability
1198 /// This function is available since SDL 3.2.0.
1199 ///
1200 /// ## See also
1201 /// - [`SDL_GetEnvironment`]
1202 /// - [`SDL_CreateEnvironment`]
1203 /// - [`SDL_GetEnvironmentVariables`]
1204 /// - [`SDL_SetEnvironmentVariable`]
1205 /// - [`SDL_UnsetEnvironmentVariable`]
1206 pub fn SDL_GetEnvironmentVariables(env: *mut SDL_Environment) -> *mut *mut ::core::ffi::c_char;
1207}
1208
1209unsafe extern "C" {
1210 /// Set the value of a variable in the environment.
1211 ///
1212 /// ## Parameters
1213 /// - `env`: the environment to modify.
1214 /// - `name`: the name of the variable to set.
1215 /// - `value`: the value of the variable to set.
1216 /// - `overwrite`: true to overwrite the variable if it exists, false to
1217 /// return success without setting the variable if it already
1218 /// exists.
1219 ///
1220 /// ## Return value
1221 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1222 /// information.
1223 ///
1224 /// ## Thread safety
1225 /// It is safe to call this function from any thread.
1226 ///
1227 /// ## Availability
1228 /// This function is available since SDL 3.2.0.
1229 ///
1230 /// ## See also
1231 /// - [`SDL_GetEnvironment`]
1232 /// - [`SDL_CreateEnvironment`]
1233 /// - [`SDL_GetEnvironmentVariable`]
1234 /// - [`SDL_GetEnvironmentVariables`]
1235 /// - [`SDL_UnsetEnvironmentVariable`]
1236 pub fn SDL_SetEnvironmentVariable(
1237 env: *mut SDL_Environment,
1238 name: *const ::core::ffi::c_char,
1239 value: *const ::core::ffi::c_char,
1240 overwrite: ::core::primitive::bool,
1241 ) -> ::core::primitive::bool;
1242}
1243
1244unsafe extern "C" {
1245 /// Clear a variable from the environment.
1246 ///
1247 /// ## Parameters
1248 /// - `env`: the environment to modify.
1249 /// - `name`: the name of the variable to unset.
1250 ///
1251 /// ## Return value
1252 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1253 /// information.
1254 ///
1255 /// ## Thread safety
1256 /// It is safe to call this function from any thread.
1257 ///
1258 /// ## Availability
1259 /// This function is available since SDL 3.2.0.
1260 ///
1261 /// ## See also
1262 /// - [`SDL_GetEnvironment`]
1263 /// - [`SDL_CreateEnvironment`]
1264 /// - [`SDL_GetEnvironmentVariable`]
1265 /// - [`SDL_GetEnvironmentVariables`]
1266 /// - [`SDL_SetEnvironmentVariable`]
1267 /// - [`SDL_UnsetEnvironmentVariable`]
1268 pub fn SDL_UnsetEnvironmentVariable(
1269 env: *mut SDL_Environment,
1270 name: *const ::core::ffi::c_char,
1271 ) -> ::core::primitive::bool;
1272}
1273
1274unsafe extern "C" {
1275 /// Destroy a set of environment variables.
1276 ///
1277 /// ## Parameters
1278 /// - `env`: the environment to destroy.
1279 ///
1280 /// ## Thread safety
1281 /// It is safe to call this function from any thread, as long as
1282 /// the environment is no longer in use.
1283 ///
1284 /// ## Availability
1285 /// This function is available since SDL 3.2.0.
1286 ///
1287 /// ## See also
1288 /// - [`SDL_CreateEnvironment`]
1289 pub fn SDL_DestroyEnvironment(env: *mut SDL_Environment);
1290}
1291
1292unsafe extern "C" {
1293 /// Get the value of a variable in the environment.
1294 ///
1295 /// This function uses SDL's cached copy of the environment and is thread-safe.
1296 ///
1297 /// ## Parameters
1298 /// - `name`: the name of the variable to get.
1299 ///
1300 /// ## Return value
1301 /// Returns a pointer to the value of the variable or NULL if it can't be
1302 /// found.
1303 ///
1304 /// ## Thread safety
1305 /// It is safe to call this function from any thread.
1306 ///
1307 /// ## Availability
1308 /// This function is available since SDL 3.2.0.
1309 pub fn SDL_getenv(name: *const ::core::ffi::c_char) -> *const ::core::ffi::c_char;
1310}
1311
1312unsafe extern "C" {
1313 /// Get the value of a variable in the environment.
1314 ///
1315 /// This function bypasses SDL's cached copy of the environment and is not
1316 /// thread-safe.
1317 ///
1318 /// ## Parameters
1319 /// - `name`: the name of the variable to get.
1320 ///
1321 /// ## Return value
1322 /// Returns a pointer to the value of the variable or NULL if it can't be
1323 /// found.
1324 ///
1325 /// ## Thread safety
1326 /// This function is not thread safe, consider using [`SDL_getenv()`]
1327 /// instead.
1328 ///
1329 /// ## Availability
1330 /// This function is available since SDL 3.2.0.
1331 ///
1332 /// ## See also
1333 /// - [`SDL_getenv`]
1334 pub fn SDL_getenv_unsafe(name: *const ::core::ffi::c_char) -> *const ::core::ffi::c_char;
1335}
1336
1337unsafe extern "C" {
1338 /// Set the value of a variable in the environment.
1339 ///
1340 /// ## Parameters
1341 /// - `name`: the name of the variable to set.
1342 /// - `value`: the value of the variable to set.
1343 /// - `overwrite`: 1 to overwrite the variable if it exists, 0 to return
1344 /// success without setting the variable if it already exists.
1345 ///
1346 /// ## Return value
1347 /// Returns 0 on success, -1 on error.
1348 ///
1349 /// ## Thread safety
1350 /// This function is not thread safe, consider using
1351 /// [`SDL_SetEnvironmentVariable()`] instead.
1352 ///
1353 /// ## Availability
1354 /// This function is available since SDL 3.2.0.
1355 ///
1356 /// ## See also
1357 /// - [`SDL_SetEnvironmentVariable`]
1358 pub fn SDL_setenv_unsafe(
1359 name: *const ::core::ffi::c_char,
1360 value: *const ::core::ffi::c_char,
1361 overwrite: ::core::ffi::c_int,
1362 ) -> ::core::ffi::c_int;
1363}
1364
1365unsafe extern "C" {
1366 /// Clear a variable from the environment.
1367 ///
1368 /// ## Parameters
1369 /// - `name`: the name of the variable to unset.
1370 ///
1371 /// ## Return value
1372 /// Returns 0 on success, -1 on error.
1373 ///
1374 /// ## Thread safety
1375 /// This function is not thread safe, consider using
1376 /// [`SDL_UnsetEnvironmentVariable()`] instead.
1377 ///
1378 /// ## Availability
1379 /// This function is available since SDL 3.2.0.
1380 ///
1381 /// ## See also
1382 /// - [`SDL_UnsetEnvironmentVariable`]
1383 pub fn SDL_unsetenv_unsafe(name: *const ::core::ffi::c_char) -> ::core::ffi::c_int;
1384}
1385
1386/// A callback used with SDL sorting and binary search functions.
1387///
1388/// ## Parameters
1389/// - `a`: a pointer to the first element being compared.
1390/// - `b`: a pointer to the second element being compared.
1391///
1392/// ## Return value
1393/// Returns -1 if `a` should be sorted before `b`, 1 if `b` should be sorted
1394/// before `a`, 0 if they are equal. If two elements are equal, their
1395/// order in the sorted array is undefined.
1396///
1397/// ## Availability
1398/// This callback is available since SDL 3.2.0.
1399///
1400/// ## See also
1401/// - [`SDL_bsearch`]
1402/// - [`SDL_qsort`]
1403pub type SDL_CompareCallback = ::core::option::Option<
1404 unsafe extern "C" fn(
1405 a: *const ::core::ffi::c_void,
1406 b: *const ::core::ffi::c_void,
1407 ) -> ::core::ffi::c_int,
1408>;
1409
1410unsafe extern "C" {
1411 /// Sort an array.
1412 ///
1413 /// For example:
1414 ///
1415 /// ```c
1416 /// typedef struct {
1417 /// int key;
1418 /// const char *string;
1419 /// } data;
1420 ///
1421 /// int SDLCALL compare(const void *a, const void *b)
1422 /// {
1423 /// const data *A = (const data *)a;
1424 /// const data *B = (const data *)b;
1425 ///
1426 /// if (A->n < B->n) {
1427 /// return -1;
1428 /// } else if (B->n < A->n) {
1429 /// return 1;
1430 /// } else {
1431 /// return 0;
1432 /// }
1433 /// }
1434 ///
1435 /// data values[] = {
1436 /// { 3, "third" }, { 1, "first" }, { 2, "second" }
1437 /// };
1438 ///
1439 /// SDL_qsort(values, SDL_arraysize(values), sizeof(values[0]), compare);
1440 /// ```
1441 ///
1442 /// ## Parameters
1443 /// - `base`: a pointer to the start of the array.
1444 /// - `nmemb`: the number of elements in the array.
1445 /// - `size`: the size of the elements in the array.
1446 /// - `compare`: a function used to compare elements in the array.
1447 ///
1448 /// ## Thread safety
1449 /// It is safe to call this function from any thread.
1450 ///
1451 /// ## Availability
1452 /// This function is available since SDL 3.2.0.
1453 ///
1454 /// ## See also
1455 /// - [`SDL_bsearch`]
1456 /// - [`SDL_qsort_r`]
1457 pub fn SDL_qsort(
1458 base: *mut ::core::ffi::c_void,
1459 nmemb: ::core::primitive::usize,
1460 size: ::core::primitive::usize,
1461 compare: SDL_CompareCallback,
1462 );
1463}
1464
1465unsafe extern "C" {
1466 /// Perform a binary search on a previously sorted array.
1467 ///
1468 /// For example:
1469 ///
1470 /// ```c
1471 /// typedef struct {
1472 /// int key;
1473 /// const char *string;
1474 /// } data;
1475 ///
1476 /// int SDLCALL compare(const void *a, const void *b)
1477 /// {
1478 /// const data *A = (const data *)a;
1479 /// const data *B = (const data *)b;
1480 ///
1481 /// if (A->n < B->n) {
1482 /// return -1;
1483 /// } else if (B->n < A->n) {
1484 /// return 1;
1485 /// } else {
1486 /// return 0;
1487 /// }
1488 /// }
1489 ///
1490 /// data values[] = {
1491 /// { 1, "first" }, { 2, "second" }, { 3, "third" }
1492 /// };
1493 /// data key = { 2, NULL };
1494 ///
1495 /// data *result = SDL_bsearch(&key, values, SDL_arraysize(values), sizeof(values[0]), compare);
1496 /// ```
1497 ///
1498 /// ## Parameters
1499 /// - `key`: a pointer to a key equal to the element being searched for.
1500 /// - `base`: a pointer to the start of the array.
1501 /// - `nmemb`: the number of elements in the array.
1502 /// - `size`: the size of the elements in the array.
1503 /// - `compare`: a function used to compare elements in the array.
1504 ///
1505 /// ## Return value
1506 /// Returns a pointer to the matching element in the array, or NULL if not
1507 /// found.
1508 ///
1509 /// ## Thread safety
1510 /// It is safe to call this function from any thread.
1511 ///
1512 /// ## Availability
1513 /// This function is available since SDL 3.2.0.
1514 ///
1515 /// ## See also
1516 /// - [`SDL_bsearch_r`]
1517 /// - [`SDL_qsort`]
1518 pub fn SDL_bsearch(
1519 key: *const ::core::ffi::c_void,
1520 base: *const ::core::ffi::c_void,
1521 nmemb: ::core::primitive::usize,
1522 size: ::core::primitive::usize,
1523 compare: SDL_CompareCallback,
1524 ) -> *mut ::core::ffi::c_void;
1525}
1526
1527/// A callback used with SDL sorting and binary search functions.
1528///
1529/// ## Parameters
1530/// - `userdata`: the `userdata` pointer passed to the sort function.
1531/// - `a`: a pointer to the first element being compared.
1532/// - `b`: a pointer to the second element being compared.
1533///
1534/// ## Return value
1535/// Returns -1 if `a` should be sorted before `b`, 1 if `b` should be sorted
1536/// before `a`, 0 if they are equal. If two elements are equal, their
1537/// order in the sorted array is undefined.
1538///
1539/// ## Availability
1540/// This callback is available since SDL 3.2.0.
1541///
1542/// ## See also
1543/// - [`SDL_qsort_r`]
1544/// - [`SDL_bsearch_r`]
1545pub type SDL_CompareCallback_r = ::core::option::Option<
1546 unsafe extern "C" fn(
1547 userdata: *mut ::core::ffi::c_void,
1548 a: *const ::core::ffi::c_void,
1549 b: *const ::core::ffi::c_void,
1550 ) -> ::core::ffi::c_int,
1551>;
1552
1553unsafe extern "C" {
1554 /// Sort an array, passing a userdata pointer to the compare function.
1555 ///
1556 /// For example:
1557 ///
1558 /// ```c
1559 /// typedef enum {
1560 /// sort_increasing,
1561 /// sort_decreasing,
1562 /// } sort_method;
1563 ///
1564 /// typedef struct {
1565 /// int key;
1566 /// const char *string;
1567 /// } data;
1568 ///
1569 /// int SDLCALL compare(const void *userdata, const void *a, const void *b)
1570 /// {
1571 /// sort_method method = (sort_method)(uintptr_t)userdata;
1572 /// const data *A = (const data *)a;
1573 /// const data *B = (const data *)b;
1574 ///
1575 /// if (A->key < B->key) {
1576 /// return (method == sort_increasing) ? -1 : 1;
1577 /// } else if (B->key < A->key) {
1578 /// return (method == sort_increasing) ? 1 : -1;
1579 /// } else {
1580 /// return 0;
1581 /// }
1582 /// }
1583 ///
1584 /// data values[] = {
1585 /// { 3, "third" }, { 1, "first" }, { 2, "second" }
1586 /// };
1587 ///
1588 /// SDL_qsort_r(values, SDL_arraysize(values), sizeof(values[0]), compare, (const void *)(uintptr_t)sort_increasing);
1589 /// ```
1590 ///
1591 /// ## Parameters
1592 /// - `base`: a pointer to the start of the array.
1593 /// - `nmemb`: the number of elements in the array.
1594 /// - `size`: the size of the elements in the array.
1595 /// - `compare`: a function used to compare elements in the array.
1596 /// - `userdata`: a pointer to pass to the compare function.
1597 ///
1598 /// ## Thread safety
1599 /// It is safe to call this function from any thread.
1600 ///
1601 /// ## Availability
1602 /// This function is available since SDL 3.2.0.
1603 ///
1604 /// ## See also
1605 /// - [`SDL_bsearch_r`]
1606 /// - [`SDL_qsort`]
1607 pub fn SDL_qsort_r(
1608 base: *mut ::core::ffi::c_void,
1609 nmemb: ::core::primitive::usize,
1610 size: ::core::primitive::usize,
1611 compare: SDL_CompareCallback_r,
1612 userdata: *mut ::core::ffi::c_void,
1613 );
1614}
1615
1616unsafe extern "C" {
1617 /// Perform a binary search on a previously sorted array, passing a userdata
1618 /// pointer to the compare function.
1619 ///
1620 /// For example:
1621 ///
1622 /// ```c
1623 /// typedef enum {
1624 /// sort_increasing,
1625 /// sort_decreasing,
1626 /// } sort_method;
1627 ///
1628 /// typedef struct {
1629 /// int key;
1630 /// const char *string;
1631 /// } data;
1632 ///
1633 /// int SDLCALL compare(const void *userdata, const void *a, const void *b)
1634 /// {
1635 /// sort_method method = (sort_method)(uintptr_t)userdata;
1636 /// const data *A = (const data *)a;
1637 /// const data *B = (const data *)b;
1638 ///
1639 /// if (A->key < B->key) {
1640 /// return (method == sort_increasing) ? -1 : 1;
1641 /// } else if (B->key < A->key) {
1642 /// return (method == sort_increasing) ? 1 : -1;
1643 /// } else {
1644 /// return 0;
1645 /// }
1646 /// }
1647 ///
1648 /// data values[] = {
1649 /// { 1, "first" }, { 2, "second" }, { 3, "third" }
1650 /// };
1651 /// data key = { 2, NULL };
1652 ///
1653 /// data *result = SDL_bsearch_r(&key, values, SDL_arraysize(values), sizeof(values[0]), compare, (const void *)(uintptr_t)sort_increasing);
1654 /// ```
1655 ///
1656 /// ## Parameters
1657 /// - `key`: a pointer to a key equal to the element being searched for.
1658 /// - `base`: a pointer to the start of the array.
1659 /// - `nmemb`: the number of elements in the array.
1660 /// - `size`: the size of the elements in the array.
1661 /// - `compare`: a function used to compare elements in the array.
1662 /// - `userdata`: a pointer to pass to the compare function.
1663 ///
1664 /// ## Return value
1665 /// Returns a pointer to the matching element in the array, or NULL if not
1666 /// found.
1667 ///
1668 /// ## Thread safety
1669 /// It is safe to call this function from any thread.
1670 ///
1671 /// ## Availability
1672 /// This function is available since SDL 3.2.0.
1673 ///
1674 /// ## See also
1675 /// - [`SDL_bsearch`]
1676 /// - [`SDL_qsort_r`]
1677 pub fn SDL_bsearch_r(
1678 key: *const ::core::ffi::c_void,
1679 base: *const ::core::ffi::c_void,
1680 nmemb: ::core::primitive::usize,
1681 size: ::core::primitive::usize,
1682 compare: SDL_CompareCallback_r,
1683 userdata: *mut ::core::ffi::c_void,
1684 ) -> *mut ::core::ffi::c_void;
1685}
1686
1687/// Compute the absolute value of `x`.
1688///
1689/// ## Parameters
1690/// - `x`: an integer value.
1691///
1692/// ## Return value
1693/// Returns the absolute value of x.
1694///
1695/// ## Thread safety
1696/// It is safe to call this function from any thread.
1697///
1698/// ## Availability
1699/// This function is available since SDL 3.2.0.
1700#[inline(always)]
1701pub const fn SDL_abs(x: ::core::ffi::c_int) -> ::core::ffi::c_int {
1702 return x.unsigned_abs() as _;
1703}
1704
1705#[inline(always)]
1706pub fn SDL_min<T: Copy + PartialOrd>(x: T, y: T) -> T {
1707 if x < y { x } else { y }
1708}
1709
1710#[inline(always)]
1711pub fn SDL_max<T: Copy + PartialOrd>(x: T, y: T) -> T {
1712 if x > y { x } else { y }
1713}
1714
1715#[inline(always)]
1716pub fn SDL_clamp<T: Copy + PartialOrd>(x: T, a: T, b: T) -> T {
1717 if x < a {
1718 a
1719 } else if x > b {
1720 b
1721 } else {
1722 x
1723 }
1724}
1725
1726unsafe extern "C" {
1727 /// Query if a character is alphabetic (a letter).
1728 ///
1729 /// **WARNING**: Regardless of system locale, this will only treat ASCII values
1730 /// for English 'a-z' and 'A-Z' as true.
1731 ///
1732 /// ## Parameters
1733 /// - `x`: character value to check.
1734 ///
1735 /// ## Return value
1736 /// Returns non-zero if x falls within the character class, zero otherwise.
1737 ///
1738 /// ## Thread safety
1739 /// It is safe to call this function from any thread.
1740 ///
1741 /// ## Availability
1742 /// This function is available since SDL 3.2.0.
1743 pub safe fn SDL_isalpha(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1744}
1745
1746unsafe extern "C" {
1747 /// Query if a character is alphabetic (a letter) or a number.
1748 ///
1749 /// **WARNING**: Regardless of system locale, this will only treat ASCII values
1750 /// for English 'a-z', 'A-Z', and '0-9' as true.
1751 ///
1752 /// ## Parameters
1753 /// - `x`: character value to check.
1754 ///
1755 /// ## Return value
1756 /// Returns non-zero if x falls within the character class, zero otherwise.
1757 ///
1758 /// ## Thread safety
1759 /// It is safe to call this function from any thread.
1760 ///
1761 /// ## Availability
1762 /// This function is available since SDL 3.2.0.
1763 pub safe fn SDL_isalnum(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1764}
1765
1766unsafe extern "C" {
1767 /// Report if a character is blank (a space or tab).
1768 ///
1769 /// **WARNING**: Regardless of system locale, this will only treat ASCII values
1770 /// 0x20 (space) or 0x9 (tab) as true.
1771 ///
1772 /// ## Parameters
1773 /// - `x`: character value to check.
1774 ///
1775 /// ## Return value
1776 /// Returns non-zero if x falls within the character class, zero otherwise.
1777 ///
1778 /// ## Thread safety
1779 /// It is safe to call this function from any thread.
1780 ///
1781 /// ## Availability
1782 /// This function is available since SDL 3.2.0.
1783 pub safe fn SDL_isblank(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1784}
1785
1786unsafe extern "C" {
1787 /// Report if a character is a control character.
1788 ///
1789 /// **WARNING**: Regardless of system locale, this will only treat ASCII values
1790 /// 0 through 0x1F, and 0x7F, as true.
1791 ///
1792 /// ## Parameters
1793 /// - `x`: character value to check.
1794 ///
1795 /// ## Return value
1796 /// Returns non-zero if x falls within the character class, zero otherwise.
1797 ///
1798 /// ## Thread safety
1799 /// It is safe to call this function from any thread.
1800 ///
1801 /// ## Availability
1802 /// This function is available since SDL 3.2.0.
1803 pub safe fn SDL_iscntrl(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1804}
1805
1806unsafe extern "C" {
1807 /// Report if a character is a numeric digit.
1808 ///
1809 /// **WARNING**: Regardless of system locale, this will only treat ASCII values
1810 /// '0' (0x30) through '9' (0x39), as true.
1811 ///
1812 /// ## Parameters
1813 /// - `x`: character value to check.
1814 ///
1815 /// ## Return value
1816 /// Returns non-zero if x falls within the character class, zero otherwise.
1817 ///
1818 /// ## Thread safety
1819 /// It is safe to call this function from any thread.
1820 ///
1821 /// ## Availability
1822 /// This function is available since SDL 3.2.0.
1823 pub safe fn SDL_isdigit(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1824}
1825
1826unsafe extern "C" {
1827 /// Report if a character is a hexadecimal digit.
1828 ///
1829 /// **WARNING**: Regardless of system locale, this will only treat ASCII values
1830 /// 'A' through 'F', 'a' through 'f', and '0' through '9', as true.
1831 ///
1832 /// ## Parameters
1833 /// - `x`: character value to check.
1834 ///
1835 /// ## Return value
1836 /// Returns non-zero if x falls within the character class, zero otherwise.
1837 ///
1838 /// ## Thread safety
1839 /// It is safe to call this function from any thread.
1840 ///
1841 /// ## Availability
1842 /// This function is available since SDL 3.2.0.
1843 pub safe fn SDL_isxdigit(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1844}
1845
1846unsafe extern "C" {
1847 /// Report if a character is a punctuation mark.
1848 ///
1849 /// **WARNING**: Regardless of system locale, this is equivalent to
1850 /// `((SDL_isgraph(x)) && (!SDL_isalnum(x)))`.
1851 ///
1852 /// ## Parameters
1853 /// - `x`: character value to check.
1854 ///
1855 /// ## Return value
1856 /// Returns non-zero if x falls within the character class, zero otherwise.
1857 ///
1858 /// ## Thread safety
1859 /// It is safe to call this function from any thread.
1860 ///
1861 /// ## Availability
1862 /// This function is available since SDL 3.2.0.
1863 ///
1864 /// ## See also
1865 /// - [`SDL_isgraph`]
1866 /// - [`SDL_isalnum`]
1867 pub safe fn SDL_ispunct(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1868}
1869
1870unsafe extern "C" {
1871 /// Report if a character is whitespace.
1872 ///
1873 /// **WARNING**: Regardless of system locale, this will only treat the
1874 /// following ASCII values as true:
1875 ///
1876 /// - space (0x20)
1877 /// - tab (0x09)
1878 /// - newline (0x0A)
1879 /// - vertical tab (0x0B)
1880 /// - form feed (0x0C)
1881 /// - return (0x0D)
1882 ///
1883 /// ## Parameters
1884 /// - `x`: character value to check.
1885 ///
1886 /// ## Return value
1887 /// Returns non-zero if x falls within the character class, zero otherwise.
1888 ///
1889 /// ## Thread safety
1890 /// It is safe to call this function from any thread.
1891 ///
1892 /// ## Availability
1893 /// This function is available since SDL 3.2.0.
1894 pub safe fn SDL_isspace(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1895}
1896
1897unsafe extern "C" {
1898 /// Report if a character is upper case.
1899 ///
1900 /// **WARNING**: Regardless of system locale, this will only treat ASCII values
1901 /// 'A' through 'Z' as true.
1902 ///
1903 /// ## Parameters
1904 /// - `x`: character value to check.
1905 ///
1906 /// ## Return value
1907 /// Returns non-zero if x falls within the character class, zero otherwise.
1908 ///
1909 /// ## Thread safety
1910 /// It is safe to call this function from any thread.
1911 ///
1912 /// ## Availability
1913 /// This function is available since SDL 3.2.0.
1914 pub safe fn SDL_isupper(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1915}
1916
1917unsafe extern "C" {
1918 /// Report if a character is lower case.
1919 ///
1920 /// **WARNING**: Regardless of system locale, this will only treat ASCII values
1921 /// 'a' through 'z' as true.
1922 ///
1923 /// ## Parameters
1924 /// - `x`: character value to check.
1925 ///
1926 /// ## Return value
1927 /// Returns non-zero if x falls within the character class, zero otherwise.
1928 ///
1929 /// ## Thread safety
1930 /// It is safe to call this function from any thread.
1931 ///
1932 /// ## Availability
1933 /// This function is available since SDL 3.2.0.
1934 pub safe fn SDL_islower(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1935}
1936
1937unsafe extern "C" {
1938 /// Report if a character is "printable".
1939 ///
1940 /// Be advised that "printable" has a definition that goes back to text
1941 /// terminals from the dawn of computing, making this a sort of special case
1942 /// function that is not suitable for Unicode (or most any) text management.
1943 ///
1944 /// **WARNING**: Regardless of system locale, this will only treat ASCII values
1945 /// ' ' (0x20) through '~' (0x7E) as true.
1946 ///
1947 /// ## Parameters
1948 /// - `x`: character value to check.
1949 ///
1950 /// ## Return value
1951 /// Returns non-zero if x falls within the character class, zero otherwise.
1952 ///
1953 /// ## Thread safety
1954 /// It is safe to call this function from any thread.
1955 ///
1956 /// ## Availability
1957 /// This function is available since SDL 3.2.0.
1958 pub safe fn SDL_isprint(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1959}
1960
1961unsafe extern "C" {
1962 /// Report if a character is any "printable" except space.
1963 ///
1964 /// Be advised that "printable" has a definition that goes back to text
1965 /// terminals from the dawn of computing, making this a sort of special case
1966 /// function that is not suitable for Unicode (or most any) text management.
1967 ///
1968 /// **WARNING**: Regardless of system locale, this is equivalent to
1969 /// `(SDL_isprint(x)) && ((x) != ' ')`.
1970 ///
1971 /// ## Parameters
1972 /// - `x`: character value to check.
1973 ///
1974 /// ## Return value
1975 /// Returns non-zero if x falls within the character class, zero otherwise.
1976 ///
1977 /// ## Thread safety
1978 /// It is safe to call this function from any thread.
1979 ///
1980 /// ## Availability
1981 /// This function is available since SDL 3.2.0.
1982 ///
1983 /// ## See also
1984 /// - [`SDL_isprint`]
1985 pub safe fn SDL_isgraph(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
1986}
1987
1988unsafe extern "C" {
1989 /// Convert low-ASCII English letters to uppercase.
1990 ///
1991 /// **WARNING**: Regardless of system locale, this will only convert ASCII
1992 /// values 'a' through 'z' to uppercase.
1993 ///
1994 /// This function returns the uppercase equivalent of `x`. If a character
1995 /// cannot be converted, or is already uppercase, this function returns `x`.
1996 ///
1997 /// ## Parameters
1998 /// - `x`: character value to check.
1999 ///
2000 /// ## Return value
2001 /// Returns capitalized version of x, or x if no conversion available.
2002 ///
2003 /// ## Thread safety
2004 /// It is safe to call this function from any thread.
2005 ///
2006 /// ## Availability
2007 /// This function is available since SDL 3.2.0.
2008 pub safe fn SDL_toupper(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
2009}
2010
2011unsafe extern "C" {
2012 /// Convert low-ASCII English letters to lowercase.
2013 ///
2014 /// **WARNING**: Regardless of system locale, this will only convert ASCII
2015 /// values 'A' through 'Z' to lowercase.
2016 ///
2017 /// This function returns the lowercase equivalent of `x`. If a character
2018 /// cannot be converted, or is already lowercase, this function returns `x`.
2019 ///
2020 /// ## Parameters
2021 /// - `x`: character value to check.
2022 ///
2023 /// ## Return value
2024 /// Returns lowercase version of x, or x if no conversion available.
2025 ///
2026 /// ## Thread safety
2027 /// It is safe to call this function from any thread.
2028 ///
2029 /// ## Availability
2030 /// This function is available since SDL 3.2.0.
2031 pub safe fn SDL_tolower(x: ::core::ffi::c_int) -> ::core::ffi::c_int;
2032}
2033
2034unsafe extern "C" {
2035 /// Calculate a CRC-16 value.
2036 ///
2037 /// <https://en.wikipedia.org/wiki/Cyclic_redundancy_check>
2038 ///
2039 /// This function can be called multiple times, to stream data to be
2040 /// checksummed in blocks. Each call must provide the previous CRC-16 return
2041 /// value to be updated with the next block. The first call to this function
2042 /// for a set of blocks should pass in a zero CRC value.
2043 ///
2044 /// ## Parameters
2045 /// - `crc`: the current checksum for this data set, or 0 for a new data set.
2046 /// - `data`: a new block of data to add to the checksum.
2047 /// - `len`: the size, in bytes, of the new block of data.
2048 ///
2049 /// ## Return value
2050 /// Returns a CRC-16 checksum value of all blocks in the data set.
2051 ///
2052 /// ## Thread safety
2053 /// It is safe to call this function from any thread.
2054 ///
2055 /// ## Availability
2056 /// This function is available since SDL 3.2.0.
2057 pub fn SDL_crc16(
2058 crc: Uint16,
2059 data: *const ::core::ffi::c_void,
2060 len: ::core::primitive::usize,
2061 ) -> Uint16;
2062}
2063
2064unsafe extern "C" {
2065 /// Calculate a CRC-32 value.
2066 ///
2067 /// <https://en.wikipedia.org/wiki/Cyclic_redundancy_check>
2068 ///
2069 /// This function can be called multiple times, to stream data to be
2070 /// checksummed in blocks. Each call must provide the previous CRC-32 return
2071 /// value to be updated with the next block. The first call to this function
2072 /// for a set of blocks should pass in a zero CRC value.
2073 ///
2074 /// ## Parameters
2075 /// - `crc`: the current checksum for this data set, or 0 for a new data set.
2076 /// - `data`: a new block of data to add to the checksum.
2077 /// - `len`: the size, in bytes, of the new block of data.
2078 ///
2079 /// ## Return value
2080 /// Returns a CRC-32 checksum value of all blocks in the data set.
2081 ///
2082 /// ## Thread safety
2083 /// It is safe to call this function from any thread.
2084 ///
2085 /// ## Availability
2086 /// This function is available since SDL 3.2.0.
2087 pub fn SDL_crc32(
2088 crc: Uint32,
2089 data: *const ::core::ffi::c_void,
2090 len: ::core::primitive::usize,
2091 ) -> Uint32;
2092}
2093
2094unsafe extern "C" {
2095 /// Calculate a 32-bit MurmurHash3 value for a block of data.
2096 ///
2097 /// <https://en.wikipedia.org/wiki/MurmurHash>
2098 ///
2099 /// A seed may be specified, which changes the final results consistently, but
2100 /// this does not work like [`SDL_crc16`] and [`SDL_crc32`]\: you can't feed a previous
2101 /// result from this function back into itself as the next seed value to
2102 /// calculate a hash in chunks; it won't produce the same hash as it would if
2103 /// the same data was provided in a single call.
2104 ///
2105 /// If you aren't sure what to provide for a seed, zero is fine. Murmur3 is not
2106 /// cryptographically secure, so it shouldn't be used for hashing top-secret
2107 /// data.
2108 ///
2109 /// ## Parameters
2110 /// - `data`: the data to be hashed.
2111 /// - `len`: the size of data, in bytes.
2112 /// - `seed`: a value that alters the final hash value.
2113 ///
2114 /// ## Return value
2115 /// Returns a Murmur3 32-bit hash value.
2116 ///
2117 /// ## Thread safety
2118 /// It is safe to call this function from any thread.
2119 ///
2120 /// ## Availability
2121 /// This function is available since SDL 3.2.0.
2122 pub fn SDL_murmur3_32(
2123 data: *const ::core::ffi::c_void,
2124 len: ::core::primitive::usize,
2125 seed: Uint32,
2126 ) -> Uint32;
2127}
2128
2129/// Copy non-overlapping memory.
2130///
2131/// The memory regions must not overlap. If they do, use [`SDL_memmove()`] instead.
2132///
2133/// ## Parameters
2134/// - `dst`: The destination memory region. Must not be NULL, and must not
2135/// overlap with `src`.
2136/// - `src`: The source memory region. Must not be NULL, and must not overlap
2137/// with `dst`.
2138/// - `len`: The length in bytes of both `dst` and `src`.
2139///
2140/// ## Return value
2141/// Returns `dst`.
2142///
2143/// ## Thread safety
2144/// It is safe to call this function from any thread.
2145///
2146/// ## Availability
2147/// This function is available since SDL 3.2.0.
2148///
2149/// ## See also
2150/// - [`SDL_memmove`]
2151#[inline(always)]
2152pub const unsafe fn SDL_memcpy(
2153 dst: *mut ::core::ffi::c_void,
2154 src: *const ::core::ffi::c_void,
2155 len: ::core::primitive::usize,
2156) -> *mut ::core::ffi::c_void {
2157 unsafe { ::core::ptr::copy_nonoverlapping(src.cast::<Uint8>(), dst.cast::<Uint8>(), len) };
2158 return dst;
2159}
2160
2161/// A macro to copy memory between objects, with basic type checking.
2162///
2163/// [`SDL_memcpy`] and [`SDL_memmove`] do not care where you copy memory to and from,
2164/// which can lead to bugs. This macro aims to avoid most of those bugs by
2165/// making sure that the source and destination are both pointers to objects
2166/// that are the same size. It does not check that the objects are the same
2167/// _type_, just that the copy will not overflow either object.
2168///
2169/// The size check happens at compile time, and the compiler will throw an
2170/// error if the objects are different sizes.
2171///
2172/// Generally this is intended to copy a single object, not an array.
2173///
2174/// This macro looks like it double-evaluates its parameters, but the extras
2175/// them are in `sizeof` sections, which generate no code nor side-effects.
2176///
2177/// ## Parameters
2178/// - `dst`: a pointer to the destination object. Must not be NULL.
2179/// - `src`: a pointer to the source object. Must not be NULL.
2180///
2181/// ## Thread safety
2182/// It is safe to call this function from any thread.
2183///
2184/// ## Availability
2185/// This function is available since SDL 3.2.0.
2186///
2187/// # Safety
2188/// It must be valid to write the memory pointed to by `src` to the memory pointed to by `dst`,
2189/// and the memory pointed to by `src` and `dst` must not overlap
2190#[inline(always)]
2191pub unsafe fn SDL_copyp<Dst: Sized, Src: Sized>(dst: *mut Dst, src: *const Src) -> *mut Dst {
2192 const { assert!(::core::mem::size_of::<Dst>() == ::core::mem::size_of::<Src>()) }
2193 unsafe {
2194 ::core::ptr::copy_nonoverlapping(
2195 src.cast::<Uint8>(),
2196 dst.cast::<Uint8>(),
2197 ::core::mem::size_of::<Src>(),
2198 )
2199 };
2200 dst
2201}
2202
2203/// Copy memory ranges that might overlap.
2204///
2205/// It is okay for the memory regions to overlap. If you are confident that the
2206/// regions never overlap, using [`SDL_memcpy()`] may improve performance.
2207///
2208/// ## Parameters
2209/// - `dst`: The destination memory region. Must not be NULL.
2210/// - `src`: The source memory region. Must not be NULL.
2211/// - `len`: The length in bytes of both `dst` and `src`.
2212///
2213/// ## Return value
2214/// Returns `dst`.
2215///
2216/// ## Thread safety
2217/// It is safe to call this function from any thread.
2218///
2219/// ## Availability
2220/// This function is available since SDL 3.2.0.
2221///
2222/// ## See also
2223/// - [`SDL_memcpy`]
2224#[inline(always)]
2225pub const unsafe fn SDL_memmove(
2226 dst: *mut ::core::ffi::c_void,
2227 src: *const ::core::ffi::c_void,
2228 len: ::core::primitive::usize,
2229) -> *mut ::core::ffi::c_void {
2230 unsafe { ::core::ptr::copy(src.cast::<Uint8>(), dst.cast::<Uint8>(), len) };
2231 return dst;
2232}
2233
2234unsafe extern "C" {
2235 /// Initialize all bytes of buffer of memory to a specific value.
2236 ///
2237 /// This function will set `len` bytes, pointed to by `dst`, to the value
2238 /// specified in `c`.
2239 ///
2240 /// Despite `c` being an `int` instead of a `char`, this only operates on
2241 /// bytes; `c` must be a value between 0 and 255, inclusive.
2242 ///
2243 /// ## Parameters
2244 /// - `dst`: the destination memory region. Must not be NULL.
2245 /// - `c`: the byte value to set.
2246 /// - `len`: the length, in bytes, to set in `dst`.
2247 ///
2248 /// ## Return value
2249 /// Returns `dst`.
2250 ///
2251 /// ## Thread safety
2252 /// It is safe to call this function from any thread.
2253 ///
2254 /// ## Availability
2255 /// This function is available since SDL 3.2.0.
2256 pub fn SDL_memset(
2257 dst: *mut ::core::ffi::c_void,
2258 c: ::core::ffi::c_int,
2259 len: ::core::primitive::usize,
2260 ) -> *mut ::core::ffi::c_void;
2261}
2262
2263unsafe extern "C" {
2264 /// Initialize all 32-bit words of buffer of memory to a specific value.
2265 ///
2266 /// This function will set a buffer of `dwords` Uint32 values, pointed to by
2267 /// `dst`, to the value specified in `val`.
2268 ///
2269 /// Unlike [`SDL_memset`], this sets 32-bit values, not bytes, so it's not limited
2270 /// to a range of 0-255.
2271 ///
2272 /// ## Parameters
2273 /// - `dst`: the destination memory region. Must not be NULL.
2274 /// - `val`: the Uint32 value to set.
2275 /// - `dwords`: the number of Uint32 values to set in `dst`.
2276 ///
2277 /// ## Return value
2278 /// Returns `dst`.
2279 ///
2280 /// ## Thread safety
2281 /// It is safe to call this function from any thread.
2282 ///
2283 /// ## Availability
2284 /// This function is available since SDL 3.2.0.
2285 pub fn SDL_memset4(
2286 dst: *mut ::core::ffi::c_void,
2287 val: Uint32,
2288 dwords: ::core::primitive::usize,
2289 ) -> *mut ::core::ffi::c_void;
2290}
2291
2292/// Clear an object's memory to zero, using a pointer.
2293///
2294/// This is wrapper over [`SDL_memset`] that handles calculating the object size,
2295/// so there's no chance of copy/paste errors, and the code is cleaner.
2296///
2297/// This requires a pointer to an object, not an object itself, nor an array.
2298///
2299/// ## Parameters
2300/// - `x`: a pointer to the object to clear.
2301///
2302/// ## Thread safety
2303/// It is safe to call this macro from any thread.
2304///
2305/// ## Availability
2306/// This macro is available since SDL 3.2.0.
2307///
2308/// ## See also
2309/// - [`SDL_zero`]
2310/// - [`SDL_zeroa`]
2311///
2312/// # Safety
2313/// It must be valid to zero all bytes of `T`, and it must be valid to write a `T` to the memory pointed to by `x`
2314#[inline(always)]
2315pub unsafe fn SDL_zerop<T>(x: *mut T) -> *mut T {
2316 unsafe { x.write_bytes(0, 1) };
2317 x
2318}
2319
2320unsafe extern "C" {
2321 /// Compare two buffers of memory.
2322 ///
2323 /// ## Parameters
2324 /// - `s1`: the first buffer to compare. NULL is not permitted!
2325 /// - `s2`: the second buffer to compare. NULL is not permitted!
2326 /// - `len`: the number of bytes to compare between the buffers.
2327 ///
2328 /// ## Return value
2329 /// Returns less than zero if s1 is "less than" s2, greater than zero if s1 is
2330 /// "greater than" s2, and zero if the buffers match exactly for `len`
2331 /// bytes.
2332 ///
2333 /// ## Thread safety
2334 /// It is safe to call this function from any thread.
2335 ///
2336 /// ## Availability
2337 /// This function is available since SDL 3.2.0.
2338 pub fn SDL_memcmp(
2339 s1: *const ::core::ffi::c_void,
2340 s2: *const ::core::ffi::c_void,
2341 len: ::core::primitive::usize,
2342 ) -> ::core::ffi::c_int;
2343}
2344
2345unsafe extern "C" {
2346 /// This works exactly like wcslen() but doesn't require access to a C runtime.
2347 ///
2348 /// Counts the number of wchar_t values in `wstr`, excluding the null
2349 /// terminator.
2350 ///
2351 /// Like [`SDL_strlen`] only counts bytes and not codepoints in a UTF-8 string,
2352 /// this counts wchar_t values in a string, even if the string's encoding is of
2353 /// variable width, like UTF-16.
2354 ///
2355 /// Also be aware that wchar_t is different sizes on different platforms (4
2356 /// bytes on Linux, 2 on Windows, etc).
2357 ///
2358 /// ## Parameters
2359 /// - `wstr`: The null-terminated wide string to read. Must not be NULL.
2360 ///
2361 /// ## Return value
2362 /// Returns the length (in wchar_t values, excluding the null terminator) of
2363 /// `wstr`.
2364 ///
2365 /// ## Thread safety
2366 /// It is safe to call this function from any thread.
2367 ///
2368 /// ## Availability
2369 /// This function is available since SDL 3.2.0.
2370 ///
2371 /// ## See also
2372 /// - [`SDL_wcsnlen`]
2373 /// - [`SDL_utf8strlen`]
2374 /// - [`SDL_utf8strnlen`]
2375 pub fn SDL_wcslen(wstr: *const crate::ffi::c_wchar_t) -> ::core::primitive::usize;
2376}
2377
2378unsafe extern "C" {
2379 /// This works exactly like wcsnlen() but doesn't require access to a C
2380 /// runtime.
2381 ///
2382 /// Counts up to a maximum of `maxlen` wchar_t values in `wstr`, excluding the
2383 /// null terminator.
2384 ///
2385 /// Like [`SDL_strnlen`] only counts bytes and not codepoints in a UTF-8 string,
2386 /// this counts wchar_t values in a string, even if the string's encoding is of
2387 /// variable width, like UTF-16.
2388 ///
2389 /// Also be aware that wchar_t is different sizes on different platforms (4
2390 /// bytes on Linux, 2 on Windows, etc).
2391 ///
2392 /// Also, `maxlen` is a count of wide characters, not bytes!
2393 ///
2394 /// ## Parameters
2395 /// - `wstr`: The null-terminated wide string to read. Must not be NULL.
2396 /// - `maxlen`: The maximum amount of wide characters to count.
2397 ///
2398 /// ## Return value
2399 /// Returns the length (in wide characters, excluding the null terminator) of
2400 /// `wstr` but never more than `maxlen`.
2401 ///
2402 /// ## Thread safety
2403 /// It is safe to call this function from any thread.
2404 ///
2405 /// ## Availability
2406 /// This function is available since SDL 3.2.0.
2407 ///
2408 /// ## See also
2409 /// - [`SDL_wcslen`]
2410 /// - [`SDL_utf8strlen`]
2411 /// - [`SDL_utf8strnlen`]
2412 pub fn SDL_wcsnlen(
2413 wstr: *const crate::ffi::c_wchar_t,
2414 maxlen: ::core::primitive::usize,
2415 ) -> ::core::primitive::usize;
2416}
2417
2418unsafe extern "C" {
2419 /// Copy a wide string.
2420 ///
2421 /// This function copies `maxlen` - 1 wide characters from `src` to `dst`, then
2422 /// appends a null terminator.
2423 ///
2424 /// `src` and `dst` must not overlap.
2425 ///
2426 /// If `maxlen` is 0, no wide characters are copied and no null terminator is
2427 /// written.
2428 ///
2429 /// ## Parameters
2430 /// - `dst`: The destination buffer. Must not be NULL, and must not overlap
2431 /// with `src`.
2432 /// - `src`: The null-terminated wide string to copy. Must not be NULL, and
2433 /// must not overlap with `dst`.
2434 /// - `maxlen`: The length (in wide characters) of the destination buffer.
2435 ///
2436 /// ## Return value
2437 /// Returns the length (in wide characters, excluding the null terminator) of
2438 /// `src`.
2439 ///
2440 /// ## Thread safety
2441 /// It is safe to call this function from any thread.
2442 ///
2443 /// ## Availability
2444 /// This function is available since SDL 3.2.0.
2445 ///
2446 /// ## See also
2447 /// - [`SDL_wcslcat`]
2448 pub fn SDL_wcslcpy(
2449 dst: *mut crate::ffi::c_wchar_t,
2450 src: *const crate::ffi::c_wchar_t,
2451 maxlen: ::core::primitive::usize,
2452 ) -> ::core::primitive::usize;
2453}
2454
2455unsafe extern "C" {
2456 /// Concatenate wide strings.
2457 ///
2458 /// This function appends up to `maxlen` - SDL_wcslen(dst) - 1 wide characters
2459 /// from `src` to the end of the wide string in `dst`, then appends a null
2460 /// terminator.
2461 ///
2462 /// `src` and `dst` must not overlap.
2463 ///
2464 /// If `maxlen` - SDL_wcslen(dst) - 1 is less than or equal to 0, then `dst` is
2465 /// unmodified.
2466 ///
2467 /// ## Parameters
2468 /// - `dst`: The destination buffer already containing the first
2469 /// null-terminated wide string. Must not be NULL and must not
2470 /// overlap with `src`.
2471 /// - `src`: The second null-terminated wide string. Must not be NULL, and
2472 /// must not overlap with `dst`.
2473 /// - `maxlen`: The length (in wide characters) of the destination buffer.
2474 ///
2475 /// ## Return value
2476 /// Returns the length (in wide characters, excluding the null terminator) of
2477 /// the string in `dst` plus the length of `src`.
2478 ///
2479 /// ## Thread safety
2480 /// It is safe to call this function from any thread.
2481 ///
2482 /// ## Availability
2483 /// This function is available since SDL 3.2.0.
2484 ///
2485 /// ## See also
2486 /// - [`SDL_wcslcpy`]
2487 pub fn SDL_wcslcat(
2488 dst: *mut crate::ffi::c_wchar_t,
2489 src: *const crate::ffi::c_wchar_t,
2490 maxlen: ::core::primitive::usize,
2491 ) -> ::core::primitive::usize;
2492}
2493
2494unsafe extern "C" {
2495 /// Allocate a copy of a wide string.
2496 ///
2497 /// This allocates enough space for a null-terminated copy of `wstr`, using
2498 /// [`SDL_malloc`], and then makes a copy of the string into this space.
2499 ///
2500 /// The returned string is owned by the caller, and should be passed to
2501 /// [`SDL_free`] when no longer needed.
2502 ///
2503 /// ## Parameters
2504 /// - `wstr`: the string to copy.
2505 ///
2506 /// ## Return value
2507 /// Returns a pointer to the newly-allocated wide string.
2508 ///
2509 /// ## Thread safety
2510 /// It is safe to call this function from any thread.
2511 ///
2512 /// ## Availability
2513 /// This function is available since SDL 3.2.0.
2514 pub fn SDL_wcsdup(wstr: *const crate::ffi::c_wchar_t) -> *mut crate::ffi::c_wchar_t;
2515}
2516
2517unsafe extern "C" {
2518 /// Search a wide string for the first instance of a specific substring.
2519 ///
2520 /// The search ends once it finds the requested substring, or a null terminator
2521 /// byte to end the string.
2522 ///
2523 /// Note that this looks for strings of _wide characters_, not _codepoints_, so
2524 /// it's legal to search for malformed and incomplete UTF-16 sequences.
2525 ///
2526 /// ## Parameters
2527 /// - `haystack`: the wide string to search. Must not be NULL.
2528 /// - `needle`: the wide string to search for. Must not be NULL.
2529 ///
2530 /// ## Return value
2531 /// Returns a pointer to the first instance of `needle` in the string, or NULL
2532 /// if not found.
2533 ///
2534 /// ## Thread safety
2535 /// It is safe to call this function from any thread.
2536 ///
2537 /// ## Availability
2538 /// This function is available since SDL 3.2.0.
2539 pub fn SDL_wcsstr(
2540 haystack: *const crate::ffi::c_wchar_t,
2541 needle: *const crate::ffi::c_wchar_t,
2542 ) -> *mut crate::ffi::c_wchar_t;
2543}
2544
2545unsafe extern "C" {
2546 /// Search a wide string, up to n wide chars, for the first instance of a
2547 /// specific substring.
2548 ///
2549 /// The search ends once it finds the requested substring, or a null terminator
2550 /// value to end the string, or `maxlen` wide character have been examined. It
2551 /// is possible to use this function on a wide string without a null
2552 /// terminator.
2553 ///
2554 /// Note that this looks for strings of _wide characters_, not _codepoints_, so
2555 /// it's legal to search for malformed and incomplete UTF-16 sequences.
2556 ///
2557 /// ## Parameters
2558 /// - `haystack`: the wide string to search. Must not be NULL.
2559 /// - `needle`: the wide string to search for. Must not be NULL.
2560 /// - `maxlen`: the maximum number of wide characters to search in
2561 /// `haystack`.
2562 ///
2563 /// ## Return value
2564 /// Returns a pointer to the first instance of `needle` in the string, or NULL
2565 /// if not found.
2566 ///
2567 /// ## Thread safety
2568 /// It is safe to call this function from any thread.
2569 ///
2570 /// ## Availability
2571 /// This function is available since SDL 3.2.0.
2572 pub fn SDL_wcsnstr(
2573 haystack: *const crate::ffi::c_wchar_t,
2574 needle: *const crate::ffi::c_wchar_t,
2575 maxlen: ::core::primitive::usize,
2576 ) -> *mut crate::ffi::c_wchar_t;
2577}
2578
2579unsafe extern "C" {
2580 /// Compare two null-terminated wide strings.
2581 ///
2582 /// This only compares wchar_t values until it hits a null-terminating
2583 /// character; it does not care if the string is well-formed UTF-16 (or UTF-32,
2584 /// depending on your platform's wchar_t size), or uses valid Unicode values.
2585 ///
2586 /// ## Parameters
2587 /// - `str1`: the first string to compare. NULL is not permitted!
2588 /// - `str2`: the second string to compare. NULL is not permitted!
2589 ///
2590 /// ## Return value
2591 /// Returns less than zero if str1 is "less than" str2, greater than zero if
2592 /// str1 is "greater than" str2, and zero if the strings match
2593 /// exactly.
2594 ///
2595 /// ## Thread safety
2596 /// It is safe to call this function from any thread.
2597 ///
2598 /// ## Availability
2599 /// This function is available since SDL 3.2.0.
2600 pub fn SDL_wcscmp(
2601 str1: *const crate::ffi::c_wchar_t,
2602 str2: *const crate::ffi::c_wchar_t,
2603 ) -> ::core::ffi::c_int;
2604}
2605
2606unsafe extern "C" {
2607 /// Compare two wide strings up to a number of wchar_t values.
2608 ///
2609 /// This only compares wchar_t values; it does not care if the string is
2610 /// well-formed UTF-16 (or UTF-32, depending on your platform's wchar_t size),
2611 /// or uses valid Unicode values.
2612 ///
2613 /// Note that while this function is intended to be used with UTF-16 (or
2614 /// UTF-32, depending on your platform's definition of wchar_t), it is
2615 /// comparing raw wchar_t values and not Unicode codepoints: `maxlen` specifies
2616 /// a wchar_t limit! If the limit lands in the middle of a multi-wchar UTF-16
2617 /// sequence, it will only compare a portion of the final character.
2618 ///
2619 /// `maxlen` specifies a maximum number of wchar_t to compare; if the strings
2620 /// match to this number of wide chars (or both have matched to a
2621 /// null-terminator character before this count), they will be considered
2622 /// equal.
2623 ///
2624 /// ## Parameters
2625 /// - `str1`: the first string to compare. NULL is not permitted!
2626 /// - `str2`: the second string to compare. NULL is not permitted!
2627 /// - `maxlen`: the maximum number of wchar_t to compare.
2628 ///
2629 /// ## Return value
2630 /// Returns less than zero if str1 is "less than" str2, greater than zero if
2631 /// str1 is "greater than" str2, and zero if the strings match
2632 /// exactly.
2633 ///
2634 /// ## Thread safety
2635 /// It is safe to call this function from any thread.
2636 ///
2637 /// ## Availability
2638 /// This function is available since SDL 3.2.0.
2639 pub fn SDL_wcsncmp(
2640 str1: *const crate::ffi::c_wchar_t,
2641 str2: *const crate::ffi::c_wchar_t,
2642 maxlen: ::core::primitive::usize,
2643 ) -> ::core::ffi::c_int;
2644}
2645
2646unsafe extern "C" {
2647 /// Compare two null-terminated wide strings, case-insensitively.
2648 ///
2649 /// This will work with Unicode strings, using a technique called
2650 /// "case-folding" to handle the vast majority of case-sensitive human
2651 /// languages regardless of system locale. It can deal with expanding values: a
2652 /// German Eszett character can compare against two ASCII 's' chars and be
2653 /// considered a match, for example. A notable exception: it does not handle
2654 /// the Turkish 'i' character; human language is complicated!
2655 ///
2656 /// Depending on your platform, "wchar_t" might be 2 bytes, and expected to be
2657 /// UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this
2658 /// handles Unicode, it expects the string to be well-formed and not a
2659 /// null-terminated string of arbitrary bytes. Characters that are not valid
2660 /// UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT
2661 /// CHARACTER), which is to say two strings of random bits may turn out to
2662 /// match if they convert to the same amount of replacement characters.
2663 ///
2664 /// ## Parameters
2665 /// - `str1`: the first string to compare. NULL is not permitted!
2666 /// - `str2`: the second string to compare. NULL is not permitted!
2667 ///
2668 /// ## Return value
2669 /// Returns less than zero if str1 is "less than" str2, greater than zero if
2670 /// str1 is "greater than" str2, and zero if the strings match
2671 /// exactly.
2672 ///
2673 /// ## Thread safety
2674 /// It is safe to call this function from any thread.
2675 ///
2676 /// ## Availability
2677 /// This function is available since SDL 3.2.0.
2678 pub fn SDL_wcscasecmp(
2679 str1: *const crate::ffi::c_wchar_t,
2680 str2: *const crate::ffi::c_wchar_t,
2681 ) -> ::core::ffi::c_int;
2682}
2683
2684unsafe extern "C" {
2685 /// Compare two wide strings, case-insensitively, up to a number of wchar_t.
2686 ///
2687 /// This will work with Unicode strings, using a technique called
2688 /// "case-folding" to handle the vast majority of case-sensitive human
2689 /// languages regardless of system locale. It can deal with expanding values: a
2690 /// German Eszett character can compare against two ASCII 's' chars and be
2691 /// considered a match, for example. A notable exception: it does not handle
2692 /// the Turkish 'i' character; human language is complicated!
2693 ///
2694 /// Depending on your platform, "wchar_t" might be 2 bytes, and expected to be
2695 /// UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this
2696 /// handles Unicode, it expects the string to be well-formed and not a
2697 /// null-terminated string of arbitrary bytes. Characters that are not valid
2698 /// UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT
2699 /// CHARACTER), which is to say two strings of random bits may turn out to
2700 /// match if they convert to the same amount of replacement characters.
2701 ///
2702 /// Note that while this function might deal with variable-sized characters,
2703 /// `maxlen` specifies a _wchar_ limit! If the limit lands in the middle of a
2704 /// multi-byte UTF-16 sequence, it may convert a portion of the final character
2705 /// to one or more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not
2706 /// to overflow a buffer.
2707 ///
2708 /// `maxlen` specifies a maximum number of wchar_t values to compare; if the
2709 /// strings match to this number of wchar_t (or both have matched to a
2710 /// null-terminator character before this number of bytes), they will be
2711 /// considered equal.
2712 ///
2713 /// ## Parameters
2714 /// - `str1`: the first string to compare. NULL is not permitted!
2715 /// - `str2`: the second string to compare. NULL is not permitted!
2716 /// - `maxlen`: the maximum number of wchar_t values to compare.
2717 ///
2718 /// ## Return value
2719 /// Returns less than zero if str1 is "less than" str2, greater than zero if
2720 /// str1 is "greater than" str2, and zero if the strings match
2721 /// exactly.
2722 ///
2723 /// ## Thread safety
2724 /// It is safe to call this function from any thread.
2725 ///
2726 /// ## Availability
2727 /// This function is available since SDL 3.2.0.
2728 pub fn SDL_wcsncasecmp(
2729 str1: *const crate::ffi::c_wchar_t,
2730 str2: *const crate::ffi::c_wchar_t,
2731 maxlen: ::core::primitive::usize,
2732 ) -> ::core::ffi::c_int;
2733}
2734
2735unsafe extern "C" {
2736 /// Parse a `long` from a wide string.
2737 ///
2738 /// If `str` starts with whitespace, then those whitespace characters are
2739 /// skipped before attempting to parse the number.
2740 ///
2741 /// If the parsed number does not fit inside a `long`, the result is clamped to
2742 /// the minimum and maximum representable `long` values.
2743 ///
2744 /// ## Parameters
2745 /// - `str`: The null-terminated wide string to read. Must not be NULL.
2746 /// - `endp`: If not NULL, the address of the first invalid wide character
2747 /// (i.e. the next character after the parsed number) will be
2748 /// written to this pointer.
2749 /// - `base`: The base of the integer to read. Supported values are 0 and 2
2750 /// to 36 inclusive. If 0, the base will be inferred from the
2751 /// number's prefix (0x for hexadecimal, 0 for octal, decimal
2752 /// otherwise).
2753 ///
2754 /// ## Return value
2755 /// Returns the parsed `long`, or 0 if no number could be parsed.
2756 ///
2757 /// ## Thread safety
2758 /// It is safe to call this function from any thread.
2759 ///
2760 /// ## Availability
2761 /// This function is available since SDL 3.2.0.
2762 ///
2763 /// ## See also
2764 /// - [`SDL_strtol`]
2765 pub fn SDL_wcstol(
2766 str: *const crate::ffi::c_wchar_t,
2767 endp: *mut *mut crate::ffi::c_wchar_t,
2768 base: ::core::ffi::c_int,
2769 ) -> ::core::ffi::c_long;
2770}
2771
2772unsafe extern "C" {
2773 /// This works exactly like strlen() but doesn't require access to a C runtime.
2774 ///
2775 /// Counts the bytes in `str`, excluding the null terminator.
2776 ///
2777 /// If you need the length of a UTF-8 string, consider using [`SDL_utf8strlen()`].
2778 ///
2779 /// ## Parameters
2780 /// - `str`: The null-terminated string to read. Must not be NULL.
2781 ///
2782 /// ## Return value
2783 /// Returns the length (in bytes, excluding the null terminator) of `src`.
2784 ///
2785 /// ## Thread safety
2786 /// It is safe to call this function from any thread.
2787 ///
2788 /// ## Availability
2789 /// This function is available since SDL 3.2.0.
2790 ///
2791 /// ## See also
2792 /// - [`SDL_strnlen`]
2793 /// - [`SDL_utf8strlen`]
2794 /// - [`SDL_utf8strnlen`]
2795 pub fn SDL_strlen(str: *const ::core::ffi::c_char) -> ::core::primitive::usize;
2796}
2797
2798unsafe extern "C" {
2799 /// This works exactly like strnlen() but doesn't require access to a C
2800 /// runtime.
2801 ///
2802 /// Counts up to a maximum of `maxlen` bytes in `str`, excluding the null
2803 /// terminator.
2804 ///
2805 /// If you need the length of a UTF-8 string, consider using [`SDL_utf8strnlen()`].
2806 ///
2807 /// ## Parameters
2808 /// - `str`: The null-terminated string to read. Must not be NULL.
2809 /// - `maxlen`: The maximum amount of bytes to count.
2810 ///
2811 /// ## Return value
2812 /// Returns the length (in bytes, excluding the null terminator) of `src` but
2813 /// never more than `maxlen`.
2814 ///
2815 /// ## Thread safety
2816 /// It is safe to call this function from any thread.
2817 ///
2818 /// ## Availability
2819 /// This function is available since SDL 3.2.0.
2820 ///
2821 /// ## See also
2822 /// - [`SDL_strlen`]
2823 /// - [`SDL_utf8strlen`]
2824 /// - [`SDL_utf8strnlen`]
2825 pub fn SDL_strnlen(
2826 str: *const ::core::ffi::c_char,
2827 maxlen: ::core::primitive::usize,
2828 ) -> ::core::primitive::usize;
2829}
2830
2831unsafe extern "C" {
2832 /// Copy a string.
2833 ///
2834 /// This function copies up to `maxlen` - 1 characters from `src` to `dst`,
2835 /// then appends a null terminator.
2836 ///
2837 /// If `maxlen` is 0, no characters are copied and no null terminator is
2838 /// written.
2839 ///
2840 /// If you want to copy an UTF-8 string but need to ensure that multi-byte
2841 /// sequences are not truncated, consider using [`SDL_utf8strlcpy()`].
2842 ///
2843 /// ## Parameters
2844 /// - `dst`: The destination buffer. Must not be NULL, and must not overlap
2845 /// with `src`.
2846 /// - `src`: The null-terminated string to copy. Must not be NULL, and must
2847 /// not overlap with `dst`.
2848 /// - `maxlen`: The length (in characters) of the destination buffer.
2849 ///
2850 /// ## Return value
2851 /// Returns the length (in characters, excluding the null terminator) of
2852 /// `src`.
2853 ///
2854 /// ## Thread safety
2855 /// It is safe to call this function from any thread.
2856 ///
2857 /// ## Availability
2858 /// This function is available since SDL 3.2.0.
2859 ///
2860 /// ## See also
2861 /// - [`SDL_strlcat`]
2862 /// - [`SDL_utf8strlcpy`]
2863 pub fn SDL_strlcpy(
2864 dst: *mut ::core::ffi::c_char,
2865 src: *const ::core::ffi::c_char,
2866 maxlen: ::core::primitive::usize,
2867 ) -> ::core::primitive::usize;
2868}
2869
2870unsafe extern "C" {
2871 /// Copy an UTF-8 string.
2872 ///
2873 /// This function copies up to `dst_bytes` - 1 bytes from `src` to `dst` while
2874 /// also ensuring that the string written to `dst` does not end in a truncated
2875 /// multi-byte sequence. Finally, it appends a null terminator.
2876 ///
2877 /// `src` and `dst` must not overlap.
2878 ///
2879 /// Note that unlike [`SDL_strlcpy()`], this function returns the number of bytes
2880 /// written, not the length of `src`.
2881 ///
2882 /// ## Parameters
2883 /// - `dst`: The destination buffer. Must not be NULL, and must not overlap
2884 /// with `src`.
2885 /// - `src`: The null-terminated UTF-8 string to copy. Must not be NULL, and
2886 /// must not overlap with `dst`.
2887 /// - `dst_bytes`: The length (in bytes) of the destination buffer. Must not
2888 /// be 0.
2889 ///
2890 /// ## Return value
2891 /// Returns the number of bytes written, excluding the null terminator.
2892 ///
2893 /// ## Thread safety
2894 /// It is safe to call this function from any thread.
2895 ///
2896 /// ## Availability
2897 /// This function is available since SDL 3.2.0.
2898 ///
2899 /// ## See also
2900 /// - [`SDL_strlcpy`]
2901 pub fn SDL_utf8strlcpy(
2902 dst: *mut ::core::ffi::c_char,
2903 src: *const ::core::ffi::c_char,
2904 dst_bytes: ::core::primitive::usize,
2905 ) -> ::core::primitive::usize;
2906}
2907
2908unsafe extern "C" {
2909 /// Concatenate strings.
2910 ///
2911 /// This function appends up to `maxlen` - SDL_strlen(dst) - 1 characters from
2912 /// `src` to the end of the string in `dst`, then appends a null terminator.
2913 ///
2914 /// `src` and `dst` must not overlap.
2915 ///
2916 /// If `maxlen` - SDL_strlen(dst) - 1 is less than or equal to 0, then `dst` is
2917 /// unmodified.
2918 ///
2919 /// ## Parameters
2920 /// - `dst`: The destination buffer already containing the first
2921 /// null-terminated string. Must not be NULL and must not overlap
2922 /// with `src`.
2923 /// - `src`: The second null-terminated string. Must not be NULL, and must
2924 /// not overlap with `dst`.
2925 /// - `maxlen`: The length (in characters) of the destination buffer.
2926 ///
2927 /// ## Return value
2928 /// Returns the length (in characters, excluding the null terminator) of the
2929 /// string in `dst` plus the length of `src`.
2930 ///
2931 /// ## Thread safety
2932 /// It is safe to call this function from any thread.
2933 ///
2934 /// ## Availability
2935 /// This function is available since SDL 3.2.0.
2936 ///
2937 /// ## See also
2938 /// - [`SDL_strlcpy`]
2939 pub fn SDL_strlcat(
2940 dst: *mut ::core::ffi::c_char,
2941 src: *const ::core::ffi::c_char,
2942 maxlen: ::core::primitive::usize,
2943 ) -> ::core::primitive::usize;
2944}
2945
2946unsafe extern "C" {
2947 /// Allocate a copy of a string.
2948 ///
2949 /// This allocates enough space for a null-terminated copy of `str`, using
2950 /// [`SDL_malloc`], and then makes a copy of the string into this space.
2951 ///
2952 /// The returned string is owned by the caller, and should be passed to
2953 /// [`SDL_free`] when no longer needed.
2954 ///
2955 /// ## Parameters
2956 /// - `str`: the string to copy.
2957 ///
2958 /// ## Return value
2959 /// Returns a pointer to the newly-allocated string.
2960 ///
2961 /// ## Thread safety
2962 /// It is safe to call this function from any thread.
2963 ///
2964 /// ## Availability
2965 /// This function is available since SDL 3.2.0.
2966 pub fn SDL_strdup(str: *const ::core::ffi::c_char) -> *mut ::core::ffi::c_char;
2967}
2968
2969unsafe extern "C" {
2970 /// Allocate a copy of a string, up to n characters.
2971 ///
2972 /// This allocates enough space for a null-terminated copy of `str`, up to
2973 /// `maxlen` bytes, using [`SDL_malloc`], and then makes a copy of the string into
2974 /// this space.
2975 ///
2976 /// If the string is longer than `maxlen` bytes, the returned string will be
2977 /// `maxlen` bytes long, plus a null-terminator character that isn't included
2978 /// in the count.
2979 ///
2980 /// The returned string is owned by the caller, and should be passed to
2981 /// [`SDL_free`] when no longer needed.
2982 ///
2983 /// ## Parameters
2984 /// - `str`: the string to copy.
2985 /// - `maxlen`: the maximum length of the copied string, not counting the
2986 /// null-terminator character.
2987 ///
2988 /// ## Return value
2989 /// Returns a pointer to the newly-allocated string.
2990 ///
2991 /// ## Thread safety
2992 /// It is safe to call this function from any thread.
2993 ///
2994 /// ## Availability
2995 /// This function is available since SDL 3.2.0.
2996 pub fn SDL_strndup(
2997 str: *const ::core::ffi::c_char,
2998 maxlen: ::core::primitive::usize,
2999 ) -> *mut ::core::ffi::c_char;
3000}
3001
3002unsafe extern "C" {
3003 /// Reverse a string's contents.
3004 ///
3005 /// This reverses a null-terminated string in-place. Only the content of the
3006 /// string is reversed; the null-terminator character remains at the end of the
3007 /// reversed string.
3008 ///
3009 /// **WARNING**: This function reverses the _bytes_ of the string, not the
3010 /// codepoints. If `str` is a UTF-8 string with Unicode codepoints > 127, this
3011 /// will ruin the string data. You should only use this function on strings
3012 /// that are completely comprised of low ASCII characters.
3013 ///
3014 /// ## Parameters
3015 /// - `str`: the string to reverse.
3016 ///
3017 /// ## Return value
3018 /// Returns `str`.
3019 ///
3020 /// ## Thread safety
3021 /// It is safe to call this function from any thread.
3022 ///
3023 /// ## Availability
3024 /// This function is available since SDL 3.2.0.
3025 pub fn SDL_strrev(str: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char;
3026}
3027
3028unsafe extern "C" {
3029 /// Convert a string to uppercase.
3030 ///
3031 /// **WARNING**: Regardless of system locale, this will only convert ASCII
3032 /// values 'A' through 'Z' to uppercase.
3033 ///
3034 /// This function operates on a null-terminated string of bytes--even if it is
3035 /// malformed UTF-8!--and converts ASCII characters 'a' through 'z' to their
3036 /// uppercase equivalents in-place, returning the original `str` pointer.
3037 ///
3038 /// ## Parameters
3039 /// - `str`: the string to convert in-place. Can not be NULL.
3040 ///
3041 /// ## Return value
3042 /// Returns the `str` pointer passed into this function.
3043 ///
3044 /// ## Thread safety
3045 /// It is safe to call this function from any thread.
3046 ///
3047 /// ## Availability
3048 /// This function is available since SDL 3.2.0.
3049 ///
3050 /// ## See also
3051 /// - [`SDL_strlwr`]
3052 pub fn SDL_strupr(str: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char;
3053}
3054
3055unsafe extern "C" {
3056 /// Convert a string to lowercase.
3057 ///
3058 /// **WARNING**: Regardless of system locale, this will only convert ASCII
3059 /// values 'A' through 'Z' to lowercase.
3060 ///
3061 /// This function operates on a null-terminated string of bytes--even if it is
3062 /// malformed UTF-8!--and converts ASCII characters 'A' through 'Z' to their
3063 /// lowercase equivalents in-place, returning the original `str` pointer.
3064 ///
3065 /// ## Parameters
3066 /// - `str`: the string to convert in-place. Can not be NULL.
3067 ///
3068 /// ## Return value
3069 /// Returns the `str` pointer passed into this function.
3070 ///
3071 /// ## Thread safety
3072 /// It is safe to call this function from any thread.
3073 ///
3074 /// ## Availability
3075 /// This function is available since SDL 3.2.0.
3076 ///
3077 /// ## See also
3078 /// - [`SDL_strupr`]
3079 pub fn SDL_strlwr(str: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char;
3080}
3081
3082unsafe extern "C" {
3083 /// Search a string for the first instance of a specific byte.
3084 ///
3085 /// The search ends once it finds the requested byte value, or a null
3086 /// terminator byte to end the string.
3087 ///
3088 /// Note that this looks for _bytes_, not _characters_, so you cannot match
3089 /// against a Unicode codepoint > 255, regardless of character encoding.
3090 ///
3091 /// ## Parameters
3092 /// - `str`: the string to search. Must not be NULL.
3093 /// - `c`: the byte value to search for.
3094 ///
3095 /// ## Return value
3096 /// Returns a pointer to the first instance of `c` in the string, or NULL if
3097 /// not found.
3098 ///
3099 /// ## Thread safety
3100 /// It is safe to call this function from any thread.
3101 ///
3102 /// ## Availability
3103 /// This function is available since SDL 3.2.0.
3104 pub fn SDL_strchr(
3105 str: *const ::core::ffi::c_char,
3106 c: ::core::ffi::c_int,
3107 ) -> *mut ::core::ffi::c_char;
3108}
3109
3110unsafe extern "C" {
3111 /// Search a string for the last instance of a specific byte.
3112 ///
3113 /// The search must go until it finds a null terminator byte to end the string.
3114 ///
3115 /// Note that this looks for _bytes_, not _characters_, so you cannot match
3116 /// against a Unicode codepoint > 255, regardless of character encoding.
3117 ///
3118 /// ## Parameters
3119 /// - `str`: the string to search. Must not be NULL.
3120 /// - `c`: the byte value to search for.
3121 ///
3122 /// ## Return value
3123 /// Returns a pointer to the last instance of `c` in the string, or NULL if
3124 /// not found.
3125 ///
3126 /// ## Thread safety
3127 /// It is safe to call this function from any thread.
3128 ///
3129 /// ## Availability
3130 /// This function is available since SDL 3.2.0.
3131 pub fn SDL_strrchr(
3132 str: *const ::core::ffi::c_char,
3133 c: ::core::ffi::c_int,
3134 ) -> *mut ::core::ffi::c_char;
3135}
3136
3137unsafe extern "C" {
3138 /// Search a string for the first instance of a specific substring.
3139 ///
3140 /// The search ends once it finds the requested substring, or a null terminator
3141 /// byte to end the string.
3142 ///
3143 /// Note that this looks for strings of _bytes_, not _characters_, so it's
3144 /// legal to search for malformed and incomplete UTF-8 sequences.
3145 ///
3146 /// ## Parameters
3147 /// - `haystack`: the string to search. Must not be NULL.
3148 /// - `needle`: the string to search for. Must not be NULL.
3149 ///
3150 /// ## Return value
3151 /// Returns a pointer to the first instance of `needle` in the string, or NULL
3152 /// if not found.
3153 ///
3154 /// ## Thread safety
3155 /// It is safe to call this function from any thread.
3156 ///
3157 /// ## Availability
3158 /// This function is available since SDL 3.2.0.
3159 pub fn SDL_strstr(
3160 haystack: *const ::core::ffi::c_char,
3161 needle: *const ::core::ffi::c_char,
3162 ) -> *mut ::core::ffi::c_char;
3163}
3164
3165unsafe extern "C" {
3166 /// Search a string, up to n bytes, for the first instance of a specific
3167 /// substring.
3168 ///
3169 /// The search ends once it finds the requested substring, or a null terminator
3170 /// byte to end the string, or `maxlen` bytes have been examined. It is
3171 /// possible to use this function on a string without a null terminator.
3172 ///
3173 /// Note that this looks for strings of _bytes_, not _characters_, so it's
3174 /// legal to search for malformed and incomplete UTF-8 sequences.
3175 ///
3176 /// ## Parameters
3177 /// - `haystack`: the string to search. Must not be NULL.
3178 /// - `needle`: the string to search for. Must not be NULL.
3179 /// - `maxlen`: the maximum number of bytes to search in `haystack`.
3180 ///
3181 /// ## Return value
3182 /// Returns a pointer to the first instance of `needle` in the string, or NULL
3183 /// if not found.
3184 ///
3185 /// ## Thread safety
3186 /// It is safe to call this function from any thread.
3187 ///
3188 /// ## Availability
3189 /// This function is available since SDL 3.2.0.
3190 pub fn SDL_strnstr(
3191 haystack: *const ::core::ffi::c_char,
3192 needle: *const ::core::ffi::c_char,
3193 maxlen: ::core::primitive::usize,
3194 ) -> *mut ::core::ffi::c_char;
3195}
3196
3197unsafe extern "C" {
3198 /// Search a UTF-8 string for the first instance of a specific substring,
3199 /// case-insensitively.
3200 ///
3201 /// This will work with Unicode strings, using a technique called
3202 /// "case-folding" to handle the vast majority of case-sensitive human
3203 /// languages regardless of system locale. It can deal with expanding values: a
3204 /// German Eszett character can compare against two ASCII 's' chars and be
3205 /// considered a match, for example. A notable exception: it does not handle
3206 /// the Turkish 'i' character; human language is complicated!
3207 ///
3208 /// Since this handles Unicode, it expects the strings to be well-formed UTF-8
3209 /// and not a null-terminated string of arbitrary bytes. Bytes that are not
3210 /// valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
3211 /// CHARACTER), which is to say two strings of random bits may turn out to
3212 /// match if they convert to the same amount of replacement characters.
3213 ///
3214 /// ## Parameters
3215 /// - `haystack`: the string to search. Must not be NULL.
3216 /// - `needle`: the string to search for. Must not be NULL.
3217 ///
3218 /// ## Return value
3219 /// Returns a pointer to the first instance of `needle` in the string, or NULL
3220 /// if not found.
3221 ///
3222 /// ## Thread safety
3223 /// It is safe to call this function from any thread.
3224 ///
3225 /// ## Availability
3226 /// This function is available since SDL 3.2.0.
3227 pub fn SDL_strcasestr(
3228 haystack: *const ::core::ffi::c_char,
3229 needle: *const ::core::ffi::c_char,
3230 ) -> *mut ::core::ffi::c_char;
3231}
3232
3233unsafe extern "C" {
3234 /// This works exactly like strtok_r() but doesn't require access to a C
3235 /// runtime.
3236 ///
3237 /// Break a string up into a series of tokens.
3238 ///
3239 /// To start tokenizing a new string, `str` should be the non-NULL address of
3240 /// the string to start tokenizing. Future calls to get the next token from the
3241 /// same string should specify a NULL.
3242 ///
3243 /// Note that this function will overwrite pieces of `str` with null chars to
3244 /// split it into tokens. This function cannot be used with const/read-only
3245 /// strings!
3246 ///
3247 /// `saveptr` just needs to point to a `char *` that can be overwritten; SDL
3248 /// will use this to save tokenizing state between calls. It is initialized if
3249 /// `str` is non-NULL, and used to resume tokenizing when `str` is NULL.
3250 ///
3251 /// ## Parameters
3252 /// - `str`: the string to tokenize, or NULL to continue tokenizing.
3253 /// - `delim`: the delimiter string that separates tokens.
3254 /// - `saveptr`: pointer to a char *, used for ongoing state.
3255 ///
3256 /// ## Return value
3257 /// Returns A pointer to the next token, or NULL if no tokens remain.
3258 ///
3259 /// ## Thread safety
3260 /// It is safe to call this function from any thread.
3261 ///
3262 /// ## Availability
3263 /// This function is available since SDL 3.2.0.
3264 pub fn SDL_strtok_r(
3265 str: *mut ::core::ffi::c_char,
3266 delim: *const ::core::ffi::c_char,
3267 saveptr: *mut *mut ::core::ffi::c_char,
3268 ) -> *mut ::core::ffi::c_char;
3269}
3270
3271unsafe extern "C" {
3272 /// Count the number of codepoints in a UTF-8 string.
3273 ///
3274 /// Counts the _codepoints_, not _bytes_, in `str`, excluding the null
3275 /// terminator.
3276 ///
3277 /// If you need to count the bytes in a string instead, consider using
3278 /// [`SDL_strlen()`].
3279 ///
3280 /// Since this handles Unicode, it expects the strings to be well-formed UTF-8
3281 /// and not a null-terminated string of arbitrary bytes. Bytes that are not
3282 /// valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
3283 /// CHARACTER), so a malformed or incomplete UTF-8 sequence might increase the
3284 /// count by several replacement characters.
3285 ///
3286 /// ## Parameters
3287 /// - `str`: The null-terminated UTF-8 string to read. Must not be NULL.
3288 ///
3289 /// ## Return value
3290 /// Returns The length (in codepoints, excluding the null terminator) of
3291 /// `src`.
3292 ///
3293 /// ## Thread safety
3294 /// It is safe to call this function from any thread.
3295 ///
3296 /// ## Availability
3297 /// This function is available since SDL 3.2.0.
3298 ///
3299 /// ## See also
3300 /// - [`SDL_utf8strnlen`]
3301 /// - [`SDL_strlen`]
3302 pub fn SDL_utf8strlen(str: *const ::core::ffi::c_char) -> ::core::primitive::usize;
3303}
3304
3305unsafe extern "C" {
3306 /// Count the number of codepoints in a UTF-8 string, up to n bytes.
3307 ///
3308 /// Counts the _codepoints_, not _bytes_, in `str`, excluding the null
3309 /// terminator.
3310 ///
3311 /// If you need to count the bytes in a string instead, consider using
3312 /// [`SDL_strnlen()`].
3313 ///
3314 /// The counting stops at `bytes` bytes (not codepoints!). This seems
3315 /// counterintuitive, but makes it easy to express the total size of the
3316 /// string's buffer.
3317 ///
3318 /// Since this handles Unicode, it expects the strings to be well-formed UTF-8
3319 /// and not a null-terminated string of arbitrary bytes. Bytes that are not
3320 /// valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
3321 /// CHARACTER), so a malformed or incomplete UTF-8 sequence might increase the
3322 /// count by several replacement characters.
3323 ///
3324 /// ## Parameters
3325 /// - `str`: The null-terminated UTF-8 string to read. Must not be NULL.
3326 /// - `bytes`: The maximum amount of bytes to count.
3327 ///
3328 /// ## Return value
3329 /// Returns The length (in codepoints, excluding the null terminator) of `src`
3330 /// but never more than `maxlen`.
3331 ///
3332 /// ## Thread safety
3333 /// It is safe to call this function from any thread.
3334 ///
3335 /// ## Availability
3336 /// This function is available since SDL 3.2.0.
3337 ///
3338 /// ## See also
3339 /// - [`SDL_utf8strlen`]
3340 /// - [`SDL_strnlen`]
3341 pub fn SDL_utf8strnlen(
3342 str: *const ::core::ffi::c_char,
3343 bytes: ::core::primitive::usize,
3344 ) -> ::core::primitive::usize;
3345}
3346
3347unsafe extern "C" {
3348 /// Convert an integer into a string.
3349 ///
3350 /// This requires a radix to specified for string format. Specifying 10
3351 /// produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
3352 /// to 36.
3353 ///
3354 /// Note that this function will overflow a buffer if `str` is not large enough
3355 /// to hold the output! It may be safer to use [`SDL_snprintf`] to clamp output, or
3356 /// [`SDL_asprintf`] to allocate a buffer. Otherwise, it doesn't hurt to allocate
3357 /// much more space than you expect to use (and don't forget possible negative
3358 /// signs, null terminator bytes, etc).
3359 ///
3360 /// ## Parameters
3361 /// - `value`: the integer to convert.
3362 /// - `str`: the buffer to write the string into.
3363 /// - `radix`: the radix to use for string generation.
3364 ///
3365 /// ## Return value
3366 /// Returns `str`.
3367 ///
3368 /// ## Thread safety
3369 /// It is safe to call this function from any thread.
3370 ///
3371 /// ## Availability
3372 /// This function is available since SDL 3.2.0.
3373 ///
3374 /// ## See also
3375 /// - [`SDL_uitoa`]
3376 /// - [`SDL_ltoa`]
3377 /// - [`SDL_lltoa`]
3378 pub fn SDL_itoa(
3379 value: ::core::ffi::c_int,
3380 str: *mut ::core::ffi::c_char,
3381 radix: ::core::ffi::c_int,
3382 ) -> *mut ::core::ffi::c_char;
3383}
3384
3385unsafe extern "C" {
3386 /// Convert an unsigned integer into a string.
3387 ///
3388 /// This requires a radix to specified for string format. Specifying 10
3389 /// produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
3390 /// to 36.
3391 ///
3392 /// Note that this function will overflow a buffer if `str` is not large enough
3393 /// to hold the output! It may be safer to use [`SDL_snprintf`] to clamp output, or
3394 /// [`SDL_asprintf`] to allocate a buffer. Otherwise, it doesn't hurt to allocate
3395 /// much more space than you expect to use (and don't forget null terminator
3396 /// bytes, etc).
3397 ///
3398 /// ## Parameters
3399 /// - `value`: the unsigned integer to convert.
3400 /// - `str`: the buffer to write the string into.
3401 /// - `radix`: the radix to use for string generation.
3402 ///
3403 /// ## Return value
3404 /// Returns `str`.
3405 ///
3406 /// ## Thread safety
3407 /// It is safe to call this function from any thread.
3408 ///
3409 /// ## Availability
3410 /// This function is available since SDL 3.2.0.
3411 ///
3412 /// ## See also
3413 /// - [`SDL_itoa`]
3414 /// - [`SDL_ultoa`]
3415 /// - [`SDL_ulltoa`]
3416 pub fn SDL_uitoa(
3417 value: ::core::ffi::c_uint,
3418 str: *mut ::core::ffi::c_char,
3419 radix: ::core::ffi::c_int,
3420 ) -> *mut ::core::ffi::c_char;
3421}
3422
3423unsafe extern "C" {
3424 /// Convert a long integer into a string.
3425 ///
3426 /// This requires a radix to specified for string format. Specifying 10
3427 /// produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
3428 /// to 36.
3429 ///
3430 /// Note that this function will overflow a buffer if `str` is not large enough
3431 /// to hold the output! It may be safer to use [`SDL_snprintf`] to clamp output, or
3432 /// [`SDL_asprintf`] to allocate a buffer. Otherwise, it doesn't hurt to allocate
3433 /// much more space than you expect to use (and don't forget possible negative
3434 /// signs, null terminator bytes, etc).
3435 ///
3436 /// ## Parameters
3437 /// - `value`: the long integer to convert.
3438 /// - `str`: the buffer to write the string into.
3439 /// - `radix`: the radix to use for string generation.
3440 ///
3441 /// ## Return value
3442 /// Returns `str`.
3443 ///
3444 /// ## Thread safety
3445 /// It is safe to call this function from any thread.
3446 ///
3447 /// ## Availability
3448 /// This function is available since SDL 3.2.0.
3449 ///
3450 /// ## See also
3451 /// - [`SDL_ultoa`]
3452 /// - [`SDL_itoa`]
3453 /// - [`SDL_lltoa`]
3454 pub fn SDL_ltoa(
3455 value: ::core::ffi::c_long,
3456 str: *mut ::core::ffi::c_char,
3457 radix: ::core::ffi::c_int,
3458 ) -> *mut ::core::ffi::c_char;
3459}
3460
3461unsafe extern "C" {
3462 /// Convert an unsigned long integer into a string.
3463 ///
3464 /// This requires a radix to specified for string format. Specifying 10
3465 /// produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
3466 /// to 36.
3467 ///
3468 /// Note that this function will overflow a buffer if `str` is not large enough
3469 /// to hold the output! It may be safer to use [`SDL_snprintf`] to clamp output, or
3470 /// [`SDL_asprintf`] to allocate a buffer. Otherwise, it doesn't hurt to allocate
3471 /// much more space than you expect to use (and don't forget null terminator
3472 /// bytes, etc).
3473 ///
3474 /// ## Parameters
3475 /// - `value`: the unsigned long integer to convert.
3476 /// - `str`: the buffer to write the string into.
3477 /// - `radix`: the radix to use for string generation.
3478 ///
3479 /// ## Return value
3480 /// Returns `str`.
3481 ///
3482 /// ## Thread safety
3483 /// It is safe to call this function from any thread.
3484 ///
3485 /// ## Availability
3486 /// This function is available since SDL 3.2.0.
3487 ///
3488 /// ## See also
3489 /// - [`SDL_ltoa`]
3490 /// - [`SDL_uitoa`]
3491 /// - [`SDL_ulltoa`]
3492 pub fn SDL_ultoa(
3493 value: ::core::ffi::c_ulong,
3494 str: *mut ::core::ffi::c_char,
3495 radix: ::core::ffi::c_int,
3496 ) -> *mut ::core::ffi::c_char;
3497}
3498
3499unsafe extern "C" {
3500 /// Convert a long long integer into a string.
3501 ///
3502 /// This requires a radix to specified for string format. Specifying 10
3503 /// produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
3504 /// to 36.
3505 ///
3506 /// Note that this function will overflow a buffer if `str` is not large enough
3507 /// to hold the output! It may be safer to use [`SDL_snprintf`] to clamp output, or
3508 /// [`SDL_asprintf`] to allocate a buffer. Otherwise, it doesn't hurt to allocate
3509 /// much more space than you expect to use (and don't forget possible negative
3510 /// signs, null terminator bytes, etc).
3511 ///
3512 /// ## Parameters
3513 /// - `value`: the long long integer to convert.
3514 /// - `str`: the buffer to write the string into.
3515 /// - `radix`: the radix to use for string generation.
3516 ///
3517 /// ## Return value
3518 /// Returns `str`.
3519 ///
3520 /// ## Thread safety
3521 /// It is safe to call this function from any thread.
3522 ///
3523 /// ## Availability
3524 /// This function is available since SDL 3.2.0.
3525 ///
3526 /// ## See also
3527 /// - [`SDL_ulltoa`]
3528 /// - [`SDL_itoa`]
3529 /// - [`SDL_ltoa`]
3530 pub fn SDL_lltoa(
3531 value: ::core::ffi::c_longlong,
3532 str: *mut ::core::ffi::c_char,
3533 radix: ::core::ffi::c_int,
3534 ) -> *mut ::core::ffi::c_char;
3535}
3536
3537unsafe extern "C" {
3538 /// Convert an unsigned long long integer into a string.
3539 ///
3540 /// This requires a radix to specified for string format. Specifying 10
3541 /// produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
3542 /// to 36.
3543 ///
3544 /// Note that this function will overflow a buffer if `str` is not large enough
3545 /// to hold the output! It may be safer to use [`SDL_snprintf`] to clamp output, or
3546 /// [`SDL_asprintf`] to allocate a buffer. Otherwise, it doesn't hurt to allocate
3547 /// much more space than you expect to use (and don't forget null terminator
3548 /// bytes, etc).
3549 ///
3550 /// ## Parameters
3551 /// - `value`: the unsigned long long integer to convert.
3552 /// - `str`: the buffer to write the string into.
3553 /// - `radix`: the radix to use for string generation.
3554 ///
3555 /// ## Return value
3556 /// Returns `str`.
3557 ///
3558 /// ## Thread safety
3559 /// It is safe to call this function from any thread.
3560 ///
3561 /// ## Availability
3562 /// This function is available since SDL 3.2.0.
3563 ///
3564 /// ## See also
3565 /// - [`SDL_lltoa`]
3566 /// - [`SDL_uitoa`]
3567 /// - [`SDL_ultoa`]
3568 pub fn SDL_ulltoa(
3569 value: ::core::ffi::c_ulonglong,
3570 str: *mut ::core::ffi::c_char,
3571 radix: ::core::ffi::c_int,
3572 ) -> *mut ::core::ffi::c_char;
3573}
3574
3575unsafe extern "C" {
3576 /// Parse an `int` from a string.
3577 ///
3578 /// The result of calling `SDL_atoi(str)` is equivalent to
3579 /// `(int)SDL_strtol(str, NULL, 10)`.
3580 ///
3581 /// ## Parameters
3582 /// - `str`: The null-terminated string to read. Must not be NULL.
3583 ///
3584 /// ## Return value
3585 /// Returns the parsed `int`.
3586 ///
3587 /// ## Thread safety
3588 /// It is safe to call this function from any thread.
3589 ///
3590 /// ## Availability
3591 /// This function is available since SDL 3.2.0.
3592 ///
3593 /// ## See also
3594 /// - [`SDL_atof`]
3595 /// - [`SDL_strtol`]
3596 /// - [`SDL_strtoul`]
3597 /// - [`SDL_strtoll`]
3598 /// - [`SDL_strtoull`]
3599 /// - [`SDL_strtod`]
3600 /// - [`SDL_itoa`]
3601 pub fn SDL_atoi(str: *const ::core::ffi::c_char) -> ::core::ffi::c_int;
3602}
3603
3604unsafe extern "C" {
3605 /// Parse a `double` from a string.
3606 ///
3607 /// The result of calling `SDL_atof(str)` is equivalent to `SDL_strtod(str,
3608 /// NULL)`.
3609 ///
3610 /// ## Parameters
3611 /// - `str`: The null-terminated string to read. Must not be NULL.
3612 ///
3613 /// ## Return value
3614 /// Returns the parsed `double`.
3615 ///
3616 /// ## Thread safety
3617 /// It is safe to call this function from any thread.
3618 ///
3619 /// ## Availability
3620 /// This function is available since SDL 3.2.0.
3621 ///
3622 /// ## See also
3623 /// - [`SDL_atoi`]
3624 /// - [`SDL_strtol`]
3625 /// - [`SDL_strtoul`]
3626 /// - [`SDL_strtoll`]
3627 /// - [`SDL_strtoull`]
3628 /// - [`SDL_strtod`]
3629 pub fn SDL_atof(str: *const ::core::ffi::c_char) -> ::core::ffi::c_double;
3630}
3631
3632unsafe extern "C" {
3633 /// Parse a `long` from a string.
3634 ///
3635 /// If `str` starts with whitespace, then those whitespace characters are
3636 /// skipped before attempting to parse the number.
3637 ///
3638 /// If the parsed number does not fit inside a `long`, the result is clamped to
3639 /// the minimum and maximum representable `long` values.
3640 ///
3641 /// ## Parameters
3642 /// - `str`: The null-terminated string to read. Must not be NULL.
3643 /// - `endp`: If not NULL, the address of the first invalid character (i.e.
3644 /// the next character after the parsed number) will be written to
3645 /// this pointer.
3646 /// - `base`: The base of the integer to read. Supported values are 0 and 2
3647 /// to 36 inclusive. If 0, the base will be inferred from the
3648 /// number's prefix (0x for hexadecimal, 0 for octal, decimal
3649 /// otherwise).
3650 ///
3651 /// ## Return value
3652 /// Returns the parsed `long`, or 0 if no number could be parsed.
3653 ///
3654 /// ## Thread safety
3655 /// It is safe to call this function from any thread.
3656 ///
3657 /// ## Availability
3658 /// This function is available since SDL 3.2.0.
3659 ///
3660 /// ## See also
3661 /// - [`SDL_atoi`]
3662 /// - [`SDL_atof`]
3663 /// - [`SDL_strtoul`]
3664 /// - [`SDL_strtoll`]
3665 /// - [`SDL_strtoull`]
3666 /// - [`SDL_strtod`]
3667 /// - [`SDL_ltoa`]
3668 /// - [`SDL_wcstol`]
3669 pub fn SDL_strtol(
3670 str: *const ::core::ffi::c_char,
3671 endp: *mut *mut ::core::ffi::c_char,
3672 base: ::core::ffi::c_int,
3673 ) -> ::core::ffi::c_long;
3674}
3675
3676unsafe extern "C" {
3677 /// Parse an `unsigned long` from a string.
3678 ///
3679 /// If `str` starts with whitespace, then those whitespace characters are
3680 /// skipped before attempting to parse the number.
3681 ///
3682 /// If the parsed number does not fit inside an `unsigned long`, the result is
3683 /// clamped to the maximum representable `unsigned long` value.
3684 ///
3685 /// ## Parameters
3686 /// - `str`: The null-terminated string to read. Must not be NULL.
3687 /// - `endp`: If not NULL, the address of the first invalid character (i.e.
3688 /// the next character after the parsed number) will be written to
3689 /// this pointer.
3690 /// - `base`: The base of the integer to read. Supported values are 0 and 2
3691 /// to 36 inclusive. If 0, the base will be inferred from the
3692 /// number's prefix (0x for hexadecimal, 0 for octal, decimal
3693 /// otherwise).
3694 ///
3695 /// ## Return value
3696 /// Returns the parsed `unsigned long`, or 0 if no number could be parsed.
3697 ///
3698 /// ## Thread safety
3699 /// It is safe to call this function from any thread.
3700 ///
3701 /// ## Availability
3702 /// This function is available since SDL 3.2.0.
3703 ///
3704 /// ## See also
3705 /// - [`SDL_atoi`]
3706 /// - [`SDL_atof`]
3707 /// - [`SDL_strtol`]
3708 /// - [`SDL_strtoll`]
3709 /// - [`SDL_strtoull`]
3710 /// - [`SDL_strtod`]
3711 /// - [`SDL_ultoa`]
3712 pub fn SDL_strtoul(
3713 str: *const ::core::ffi::c_char,
3714 endp: *mut *mut ::core::ffi::c_char,
3715 base: ::core::ffi::c_int,
3716 ) -> ::core::ffi::c_ulong;
3717}
3718
3719unsafe extern "C" {
3720 /// Parse a `long long` from a string.
3721 ///
3722 /// If `str` starts with whitespace, then those whitespace characters are
3723 /// skipped before attempting to parse the number.
3724 ///
3725 /// If the parsed number does not fit inside a `long long`, the result is
3726 /// clamped to the minimum and maximum representable `long long` values.
3727 ///
3728 /// ## Parameters
3729 /// - `str`: The null-terminated string to read. Must not be NULL.
3730 /// - `endp`: If not NULL, the address of the first invalid character (i.e.
3731 /// the next character after the parsed number) will be written to
3732 /// this pointer.
3733 /// - `base`: The base of the integer to read. Supported values are 0 and 2
3734 /// to 36 inclusive. If 0, the base will be inferred from the
3735 /// number's prefix (0x for hexadecimal, 0 for octal, decimal
3736 /// otherwise).
3737 ///
3738 /// ## Return value
3739 /// Returns the parsed `long long`, or 0 if no number could be parsed.
3740 ///
3741 /// ## Thread safety
3742 /// It is safe to call this function from any thread.
3743 ///
3744 /// ## Availability
3745 /// This function is available since SDL 3.2.0.
3746 ///
3747 /// ## See also
3748 /// - [`SDL_atoi`]
3749 /// - [`SDL_atof`]
3750 /// - [`SDL_strtol`]
3751 /// - [`SDL_strtoul`]
3752 /// - [`SDL_strtoull`]
3753 /// - [`SDL_strtod`]
3754 /// - [`SDL_lltoa`]
3755 pub fn SDL_strtoll(
3756 str: *const ::core::ffi::c_char,
3757 endp: *mut *mut ::core::ffi::c_char,
3758 base: ::core::ffi::c_int,
3759 ) -> ::core::ffi::c_longlong;
3760}
3761
3762unsafe extern "C" {
3763 /// Parse an `unsigned long long` from a string.
3764 ///
3765 /// If `str` starts with whitespace, then those whitespace characters are
3766 /// skipped before attempting to parse the number.
3767 ///
3768 /// If the parsed number does not fit inside an `unsigned long long`, the
3769 /// result is clamped to the maximum representable `unsigned long long` value.
3770 ///
3771 /// ## Parameters
3772 /// - `str`: The null-terminated string to read. Must not be NULL.
3773 /// - `endp`: If not NULL, the address of the first invalid character (i.e.
3774 /// the next character after the parsed number) will be written to
3775 /// this pointer.
3776 /// - `base`: The base of the integer to read. Supported values are 0 and 2
3777 /// to 36 inclusive. If 0, the base will be inferred from the
3778 /// number's prefix (0x for hexadecimal, 0 for octal, decimal
3779 /// otherwise).
3780 ///
3781 /// ## Return value
3782 /// Returns the parsed `unsigned long long`, or 0 if no number could be
3783 /// parsed.
3784 ///
3785 /// ## Thread safety
3786 /// It is safe to call this function from any thread.
3787 ///
3788 /// ## Availability
3789 /// This function is available since SDL 3.2.0.
3790 ///
3791 /// ## See also
3792 /// - [`SDL_atoi`]
3793 /// - [`SDL_atof`]
3794 /// - [`SDL_strtol`]
3795 /// - [`SDL_strtoll`]
3796 /// - [`SDL_strtoul`]
3797 /// - [`SDL_strtod`]
3798 /// - [`SDL_ulltoa`]
3799 pub fn SDL_strtoull(
3800 str: *const ::core::ffi::c_char,
3801 endp: *mut *mut ::core::ffi::c_char,
3802 base: ::core::ffi::c_int,
3803 ) -> ::core::ffi::c_ulonglong;
3804}
3805
3806unsafe extern "C" {
3807 /// Parse a `double` from a string.
3808 ///
3809 /// This function makes fewer guarantees than the C runtime `strtod`:
3810 ///
3811 /// - Only decimal notation is guaranteed to be supported. The handling of
3812 /// scientific and hexadecimal notation is unspecified.
3813 /// - Whether or not INF and NAN can be parsed is unspecified.
3814 /// - The precision of the result is unspecified.
3815 ///
3816 /// ## Parameters
3817 /// - `str`: the null-terminated string to read. Must not be NULL.
3818 /// - `endp`: if not NULL, the address of the first invalid character (i.e.
3819 /// the next character after the parsed number) will be written to
3820 /// this pointer.
3821 ///
3822 /// ## Return value
3823 /// Returns the parsed `double`, or 0 if no number could be parsed.
3824 ///
3825 /// ## Thread safety
3826 /// It is safe to call this function from any thread.
3827 ///
3828 /// ## Availability
3829 /// This function is available since SDL 3.2.0.
3830 ///
3831 /// ## See also
3832 /// - [`SDL_atoi`]
3833 /// - [`SDL_atof`]
3834 /// - [`SDL_strtol`]
3835 /// - [`SDL_strtoll`]
3836 /// - [`SDL_strtoul`]
3837 /// - [`SDL_strtoull`]
3838 pub fn SDL_strtod(
3839 str: *const ::core::ffi::c_char,
3840 endp: *mut *mut ::core::ffi::c_char,
3841 ) -> ::core::ffi::c_double;
3842}
3843
3844unsafe extern "C" {
3845 /// Compare two null-terminated UTF-8 strings.
3846 ///
3847 /// Due to the nature of UTF-8 encoding, this will work with Unicode strings,
3848 /// since effectively this function just compares bytes until it hits a
3849 /// null-terminating character. Also due to the nature of UTF-8, this can be
3850 /// used with [`SDL_qsort()`] to put strings in (roughly) alphabetical order.
3851 ///
3852 /// ## Parameters
3853 /// - `str1`: the first string to compare. NULL is not permitted!
3854 /// - `str2`: the second string to compare. NULL is not permitted!
3855 ///
3856 /// ## Return value
3857 /// Returns less than zero if str1 is "less than" str2, greater than zero if
3858 /// str1 is "greater than" str2, and zero if the strings match
3859 /// exactly.
3860 ///
3861 /// ## Thread safety
3862 /// It is safe to call this function from any thread.
3863 ///
3864 /// ## Availability
3865 /// This function is available since SDL 3.2.0.
3866 pub fn SDL_strcmp(
3867 str1: *const ::core::ffi::c_char,
3868 str2: *const ::core::ffi::c_char,
3869 ) -> ::core::ffi::c_int;
3870}
3871
3872unsafe extern "C" {
3873 /// Compare two UTF-8 strings up to a number of bytes.
3874 ///
3875 /// Due to the nature of UTF-8 encoding, this will work with Unicode strings,
3876 /// since effectively this function just compares bytes until it hits a
3877 /// null-terminating character. Also due to the nature of UTF-8, this can be
3878 /// used with [`SDL_qsort()`] to put strings in (roughly) alphabetical order.
3879 ///
3880 /// Note that while this function is intended to be used with UTF-8, it is
3881 /// doing a bytewise comparison, and `maxlen` specifies a _byte_ limit! If the
3882 /// limit lands in the middle of a multi-byte UTF-8 sequence, it will only
3883 /// compare a portion of the final character.
3884 ///
3885 /// `maxlen` specifies a maximum number of bytes to compare; if the strings
3886 /// match to this number of bytes (or both have matched to a null-terminator
3887 /// character before this number of bytes), they will be considered equal.
3888 ///
3889 /// ## Parameters
3890 /// - `str1`: the first string to compare. NULL is not permitted!
3891 /// - `str2`: the second string to compare. NULL is not permitted!
3892 /// - `maxlen`: the maximum number of _bytes_ to compare.
3893 ///
3894 /// ## Return value
3895 /// Returns less than zero if str1 is "less than" str2, greater than zero if
3896 /// str1 is "greater than" str2, and zero if the strings match
3897 /// exactly.
3898 ///
3899 /// ## Thread safety
3900 /// It is safe to call this function from any thread.
3901 ///
3902 /// ## Availability
3903 /// This function is available since SDL 3.2.0.
3904 pub fn SDL_strncmp(
3905 str1: *const ::core::ffi::c_char,
3906 str2: *const ::core::ffi::c_char,
3907 maxlen: ::core::primitive::usize,
3908 ) -> ::core::ffi::c_int;
3909}
3910
3911unsafe extern "C" {
3912 /// Compare two null-terminated UTF-8 strings, case-insensitively.
3913 ///
3914 /// This will work with Unicode strings, using a technique called
3915 /// "case-folding" to handle the vast majority of case-sensitive human
3916 /// languages regardless of system locale. It can deal with expanding values: a
3917 /// German Eszett character can compare against two ASCII 's' chars and be
3918 /// considered a match, for example. A notable exception: it does not handle
3919 /// the Turkish 'i' character; human language is complicated!
3920 ///
3921 /// Since this handles Unicode, it expects the string to be well-formed UTF-8
3922 /// and not a null-terminated string of arbitrary bytes. Bytes that are not
3923 /// valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
3924 /// CHARACTER), which is to say two strings of random bits may turn out to
3925 /// match if they convert to the same amount of replacement characters.
3926 ///
3927 /// ## Parameters
3928 /// - `str1`: the first string to compare. NULL is not permitted!
3929 /// - `str2`: the second string to compare. NULL is not permitted!
3930 ///
3931 /// ## Return value
3932 /// Returns less than zero if str1 is "less than" str2, greater than zero if
3933 /// str1 is "greater than" str2, and zero if the strings match
3934 /// exactly.
3935 ///
3936 /// ## Thread safety
3937 /// It is safe to call this function from any thread.
3938 ///
3939 /// ## Availability
3940 /// This function is available since SDL 3.2.0.
3941 pub fn SDL_strcasecmp(
3942 str1: *const ::core::ffi::c_char,
3943 str2: *const ::core::ffi::c_char,
3944 ) -> ::core::ffi::c_int;
3945}
3946
3947unsafe extern "C" {
3948 /// Compare two UTF-8 strings, case-insensitively, up to a number of bytes.
3949 ///
3950 /// This will work with Unicode strings, using a technique called
3951 /// "case-folding" to handle the vast majority of case-sensitive human
3952 /// languages regardless of system locale. It can deal with expanding values: a
3953 /// German Eszett character can compare against two ASCII 's' chars and be
3954 /// considered a match, for example. A notable exception: it does not handle
3955 /// the Turkish 'i' character; human language is complicated!
3956 ///
3957 /// Since this handles Unicode, it expects the string to be well-formed UTF-8
3958 /// and not a null-terminated string of arbitrary bytes. Bytes that are not
3959 /// valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
3960 /// CHARACTER), which is to say two strings of random bits may turn out to
3961 /// match if they convert to the same amount of replacement characters.
3962 ///
3963 /// Note that while this function is intended to be used with UTF-8, `maxlen`
3964 /// specifies a _byte_ limit! If the limit lands in the middle of a multi-byte
3965 /// UTF-8 sequence, it may convert a portion of the final character to one or
3966 /// more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not to overflow
3967 /// a buffer.
3968 ///
3969 /// `maxlen` specifies a maximum number of bytes to compare; if the strings
3970 /// match to this number of bytes (or both have matched to a null-terminator
3971 /// character before this number of bytes), they will be considered equal.
3972 ///
3973 /// ## Parameters
3974 /// - `str1`: the first string to compare. NULL is not permitted!
3975 /// - `str2`: the second string to compare. NULL is not permitted!
3976 /// - `maxlen`: the maximum number of bytes to compare.
3977 ///
3978 /// ## Return value
3979 /// Returns less than zero if str1 is "less than" str2, greater than zero if
3980 /// str1 is "greater than" str2, and zero if the strings match
3981 /// exactly.
3982 ///
3983 /// ## Thread safety
3984 /// It is safe to call this function from any thread.
3985 ///
3986 /// ## Availability
3987 /// This function is available since SDL 3.2.0.
3988 pub fn SDL_strncasecmp(
3989 str1: *const ::core::ffi::c_char,
3990 str2: *const ::core::ffi::c_char,
3991 maxlen: ::core::primitive::usize,
3992 ) -> ::core::ffi::c_int;
3993}
3994
3995unsafe extern "C" {
3996 /// Searches a string for the first occurrence of any character contained in a
3997 /// breakset, and returns a pointer from the string to that character.
3998 ///
3999 /// ## Parameters
4000 /// - `str`: The null-terminated string to be searched. Must not be NULL, and
4001 /// must not overlap with `breakset`.
4002 /// - `breakset`: A null-terminated string containing the list of characters
4003 /// to look for. Must not be NULL, and must not overlap with
4004 /// `str`.
4005 ///
4006 /// ## Return value
4007 /// Returns A pointer to the location, in str, of the first occurrence of a
4008 /// character present in the breakset, or NULL if none is found.
4009 ///
4010 /// ## Thread safety
4011 /// It is safe to call this function from any thread.
4012 ///
4013 /// ## Availability
4014 /// This function is available since SDL 3.2.0.
4015 pub fn SDL_strpbrk(
4016 str: *const ::core::ffi::c_char,
4017 breakset: *const ::core::ffi::c_char,
4018 ) -> *mut ::core::ffi::c_char;
4019}
4020
4021/// The Unicode REPLACEMENT CHARACTER codepoint.
4022///
4023/// [`SDL_StepUTF8()`] and [`SDL_StepBackUTF8()`] report this codepoint when they
4024/// encounter a UTF-8 string with encoding errors.
4025///
4026/// This tends to render as something like a question mark in most places.
4027///
4028/// ## Availability
4029/// This macro is available since SDL 3.2.0.
4030///
4031/// ## See also
4032/// - [`SDL_StepBackUTF8`]
4033/// - [`SDL_StepUTF8`]
4034pub const SDL_INVALID_UNICODE_CODEPOINT: ::core::primitive::i32 = 65533;
4035
4036unsafe extern "C" {
4037 /// Decode a UTF-8 string, one Unicode codepoint at a time.
4038 ///
4039 /// This will return the first Unicode codepoint in the UTF-8 encoded string in
4040 /// `*pstr`, and then advance `*pstr` past any consumed bytes before returning.
4041 ///
4042 /// It will not access more than `*pslen` bytes from the string. `*pslen` will
4043 /// be adjusted, as well, subtracting the number of bytes consumed.
4044 ///
4045 /// `pslen` is allowed to be NULL, in which case the string _must_ be
4046 /// NULL-terminated, as the function will blindly read until it sees the NULL
4047 /// char.
4048 ///
4049 /// if `*pslen` is zero, it assumes the end of string is reached and returns a
4050 /// zero codepoint regardless of the contents of the string buffer.
4051 ///
4052 /// If the resulting codepoint is zero (a NULL terminator), or `*pslen` is
4053 /// zero, it will not advance `*pstr` or `*pslen` at all.
4054 ///
4055 /// Generally this function is called in a loop until it returns zero,
4056 /// adjusting its parameters each iteration.
4057 ///
4058 /// If an invalid UTF-8 sequence is encountered, this function returns
4059 /// [`SDL_INVALID_UNICODE_CODEPOINT`] and advances the string/length by one byte
4060 /// (which is to say, a multibyte sequence might produce several
4061 /// [`SDL_INVALID_UNICODE_CODEPOINT`] returns before it syncs to the next valid
4062 /// UTF-8 sequence).
4063 ///
4064 /// Several things can generate invalid UTF-8 sequences, including overlong
4065 /// encodings, the use of UTF-16 surrogate values, and truncated data. Please
4066 /// refer to
4067 /// [RFC3629](https://www.ietf.org/rfc/rfc3629.txt)
4068 /// for details.
4069 ///
4070 /// ## Parameters
4071 /// - `pstr`: a pointer to a UTF-8 string pointer to be read and adjusted.
4072 /// - `pslen`: a pointer to the number of bytes in the string, to be read and
4073 /// adjusted. NULL is allowed.
4074 ///
4075 /// ## Return value
4076 /// Returns the first Unicode codepoint in the string.
4077 ///
4078 /// ## Thread safety
4079 /// It is safe to call this function from any thread.
4080 ///
4081 /// ## Availability
4082 /// This function is available since SDL 3.2.0.
4083 pub fn SDL_StepUTF8(
4084 pstr: *mut *const ::core::ffi::c_char,
4085 pslen: *mut ::core::primitive::usize,
4086 ) -> Uint32;
4087}
4088
4089unsafe extern "C" {
4090 /// Decode a UTF-8 string in reverse, one Unicode codepoint at a time.
4091 ///
4092 /// This will go to the start of the previous Unicode codepoint in the string,
4093 /// move `*pstr` to that location and return that codepoint.
4094 ///
4095 /// If `*pstr` is already at the start of the string), it will not advance
4096 /// `*pstr` at all.
4097 ///
4098 /// Generally this function is called in a loop until it returns zero,
4099 /// adjusting its parameter each iteration.
4100 ///
4101 /// If an invalid UTF-8 sequence is encountered, this function returns
4102 /// [`SDL_INVALID_UNICODE_CODEPOINT`].
4103 ///
4104 /// Several things can generate invalid UTF-8 sequences, including overlong
4105 /// encodings, the use of UTF-16 surrogate values, and truncated data. Please
4106 /// refer to
4107 /// [RFC3629](https://www.ietf.org/rfc/rfc3629.txt)
4108 /// for details.
4109 ///
4110 /// ## Parameters
4111 /// - `start`: a pointer to the beginning of the UTF-8 string.
4112 /// - `pstr`: a pointer to a UTF-8 string pointer to be read and adjusted.
4113 ///
4114 /// ## Return value
4115 /// Returns the previous Unicode codepoint in the string.
4116 ///
4117 /// ## Thread safety
4118 /// It is safe to call this function from any thread.
4119 ///
4120 /// ## Availability
4121 /// This function is available since SDL 3.2.0.
4122 pub fn SDL_StepBackUTF8(
4123 start: *const ::core::ffi::c_char,
4124 pstr: *mut *const ::core::ffi::c_char,
4125 ) -> Uint32;
4126}
4127
4128unsafe extern "C" {
4129 /// Convert a single Unicode codepoint to UTF-8.
4130 ///
4131 /// The buffer pointed to by `dst` must be at least 4 bytes long, as this
4132 /// function may generate between 1 and 4 bytes of output.
4133 ///
4134 /// This function returns the first byte _after_ the newly-written UTF-8
4135 /// sequence, which is useful for encoding multiple codepoints in a loop, or
4136 /// knowing where to write a NULL-terminator character to end the string (in
4137 /// either case, plan to have a buffer of _more_ than 4 bytes!).
4138 ///
4139 /// If `codepoint` is an invalid value (outside the Unicode range, or a UTF-16
4140 /// surrogate value, etc), this will use U+FFFD (REPLACEMENT CHARACTER) for the
4141 /// codepoint instead, and not set an error.
4142 ///
4143 /// If `dst` is NULL, this returns NULL immediately without writing to the
4144 /// pointer and without setting an error.
4145 ///
4146 /// ## Parameters
4147 /// - `codepoint`: a Unicode codepoint to convert to UTF-8.
4148 /// - `dst`: the location to write the encoded UTF-8. Must point to at least
4149 /// 4 bytes!
4150 ///
4151 /// ## Return value
4152 /// Returns the first byte past the newly-written UTF-8 sequence.
4153 ///
4154 /// ## Thread safety
4155 /// It is safe to call this function from any thread.
4156 ///
4157 /// ## Availability
4158 /// This function is available since SDL 3.2.0.
4159 pub fn SDL_UCS4ToUTF8(
4160 codepoint: Uint32,
4161 dst: *mut ::core::ffi::c_char,
4162 ) -> *mut ::core::ffi::c_char;
4163}
4164
4165unsafe extern "C" {
4166 /// This works exactly like sscanf() but doesn't require access to a C runtime.
4167 ///
4168 /// Scan a string, matching a format string, converting each '%' item and
4169 /// storing it to pointers provided through variable arguments.
4170 ///
4171 /// ## Parameters
4172 /// - `text`: the string to scan. Must not be NULL.
4173 /// - `fmt`: a printf-style format string. Must not be NULL.
4174 /// - `...`: a list of pointers to values to be filled in with scanned items.
4175 ///
4176 /// ## Return value
4177 /// Returns the number of items that matched the format string.
4178 ///
4179 /// ## Thread safety
4180 /// It is safe to call this function from any thread.
4181 ///
4182 /// ## Availability
4183 /// This function is available since SDL 3.2.0.
4184 pub fn SDL_sscanf(
4185 text: *const ::core::ffi::c_char,
4186 fmt: *const ::core::ffi::c_char,
4187 ...
4188 ) -> ::core::ffi::c_int;
4189}
4190
4191unsafe extern "C" {
4192 /// This works exactly like vsscanf() but doesn't require access to a C
4193 /// runtime.
4194 ///
4195 /// Functions identically to [`SDL_sscanf()`], except it takes a `va_list` instead
4196 /// of using `...` variable arguments.
4197 ///
4198 /// ## Parameters
4199 /// - `text`: the string to scan. Must not be NULL.
4200 /// - `fmt`: a printf-style format string. Must not be NULL.
4201 /// - `ap`: a `va_list` of pointers to values to be filled in with scanned
4202 /// items.
4203 ///
4204 /// ## Return value
4205 /// Returns the number of items that matched the format string.
4206 ///
4207 /// ## Thread safety
4208 /// It is safe to call this function from any thread.
4209 ///
4210 /// ## Availability
4211 /// This function is available since SDL 3.2.0.
4212 pub fn SDL_vsscanf(
4213 text: *const ::core::ffi::c_char,
4214 fmt: *const ::core::ffi::c_char,
4215 ap: crate::ffi::VaList,
4216 ) -> ::core::ffi::c_int;
4217}
4218
4219unsafe extern "C" {
4220 /// This works exactly like snprintf() but doesn't require access to a C
4221 /// runtime.
4222 ///
4223 /// Format a string of up to `maxlen`-1 bytes, converting each '%' item with
4224 /// values provided through variable arguments.
4225 ///
4226 /// While some C runtimes differ on how to deal with too-large strings, this
4227 /// function null-terminates the output, by treating the null-terminator as
4228 /// part of the `maxlen` count. Note that if `maxlen` is zero, however, no
4229 /// bytes will be written at all.
4230 ///
4231 /// This function returns the number of _bytes_ (not _characters_) that should
4232 /// be written, excluding the null-terminator character. If this returns a
4233 /// number >= `maxlen`, it means the output string was truncated. A negative
4234 /// return value means an error occurred.
4235 ///
4236 /// Referencing the output string's pointer with a format item is undefined
4237 /// behavior.
4238 ///
4239 /// ## Parameters
4240 /// - `text`: the buffer to write the string into. Must not be NULL.
4241 /// - `maxlen`: the maximum bytes to write, including the null-terminator.
4242 /// - `fmt`: a printf-style format string. Must not be NULL.
4243 /// - `...`: a list of values to be used with the format string.
4244 ///
4245 /// ## Return value
4246 /// Returns the number of bytes that should be written, not counting the
4247 /// null-terminator char, or a negative value on error.
4248 ///
4249 /// ## Thread safety
4250 /// It is safe to call this function from any thread.
4251 ///
4252 /// ## Availability
4253 /// This function is available since SDL 3.2.0.
4254 pub fn SDL_snprintf(
4255 text: *mut ::core::ffi::c_char,
4256 maxlen: ::core::primitive::usize,
4257 fmt: *const ::core::ffi::c_char,
4258 ...
4259 ) -> ::core::ffi::c_int;
4260}
4261
4262unsafe extern "C" {
4263 /// This works exactly like swprintf() but doesn't require access to a C
4264 /// runtime.
4265 ///
4266 /// Format a wide string of up to `maxlen`-1 wchar_t values, converting each
4267 /// '%' item with values provided through variable arguments.
4268 ///
4269 /// While some C runtimes differ on how to deal with too-large strings, this
4270 /// function null-terminates the output, by treating the null-terminator as
4271 /// part of the `maxlen` count. Note that if `maxlen` is zero, however, no wide
4272 /// characters will be written at all.
4273 ///
4274 /// This function returns the number of _wide characters_ (not _codepoints_)
4275 /// that should be written, excluding the null-terminator character. If this
4276 /// returns a number >= `maxlen`, it means the output string was truncated. A
4277 /// negative return value means an error occurred.
4278 ///
4279 /// Referencing the output string's pointer with a format item is undefined
4280 /// behavior.
4281 ///
4282 /// ## Parameters
4283 /// - `text`: the buffer to write the wide string into. Must not be NULL.
4284 /// - `maxlen`: the maximum wchar_t values to write, including the
4285 /// null-terminator.
4286 /// - `fmt`: a printf-style format string. Must not be NULL.
4287 /// - `...`: a list of values to be used with the format string.
4288 ///
4289 /// ## Return value
4290 /// Returns the number of wide characters that should be written, not counting
4291 /// the null-terminator char, or a negative value on error.
4292 ///
4293 /// ## Thread safety
4294 /// It is safe to call this function from any thread.
4295 ///
4296 /// ## Availability
4297 /// This function is available since SDL 3.2.0.
4298 pub fn SDL_swprintf(
4299 text: *mut crate::ffi::c_wchar_t,
4300 maxlen: ::core::primitive::usize,
4301 fmt: *const crate::ffi::c_wchar_t,
4302 ...
4303 ) -> ::core::ffi::c_int;
4304}
4305
4306unsafe extern "C" {
4307 /// This works exactly like vsnprintf() but doesn't require access to a C
4308 /// runtime.
4309 ///
4310 /// Functions identically to [`SDL_snprintf()`], except it takes a `va_list`
4311 /// instead of using `...` variable arguments.
4312 ///
4313 /// ## Parameters
4314 /// - `text`: the buffer to write the string into. Must not be NULL.
4315 /// - `maxlen`: the maximum bytes to write, including the null-terminator.
4316 /// - `fmt`: a printf-style format string. Must not be NULL.
4317 /// - `ap`: a `va_list` values to be used with the format string.
4318 ///
4319 /// ## Return value
4320 /// Returns the number of bytes that should be written, not counting the
4321 /// null-terminator char, or a negative value on error.
4322 ///
4323 /// ## Thread safety
4324 /// It is safe to call this function from any thread.
4325 ///
4326 /// ## Availability
4327 /// This function is available since SDL 3.2.0.
4328 pub fn SDL_vsnprintf(
4329 text: *mut ::core::ffi::c_char,
4330 maxlen: ::core::primitive::usize,
4331 fmt: *const ::core::ffi::c_char,
4332 ap: crate::ffi::VaList,
4333 ) -> ::core::ffi::c_int;
4334}
4335
4336unsafe extern "C" {
4337 /// This works exactly like vswprintf() but doesn't require access to a C
4338 /// runtime.
4339 ///
4340 /// Functions identically to [`SDL_swprintf()`], except it takes a `va_list`
4341 /// instead of using `...` variable arguments.
4342 ///
4343 /// ## Parameters
4344 /// - `text`: the buffer to write the string into. Must not be NULL.
4345 /// - `maxlen`: the maximum wide characters to write, including the
4346 /// null-terminator.
4347 /// - `fmt`: a printf-style format wide string. Must not be NULL.
4348 /// - `ap`: a `va_list` values to be used with the format string.
4349 ///
4350 /// ## Return value
4351 /// Returns the number of wide characters that should be written, not counting
4352 /// the null-terminator char, or a negative value on error.
4353 ///
4354 /// ## Thread safety
4355 /// It is safe to call this function from any thread.
4356 ///
4357 /// ## Availability
4358 /// This function is available since SDL 3.2.0.
4359 pub fn SDL_vswprintf(
4360 text: *mut crate::ffi::c_wchar_t,
4361 maxlen: ::core::primitive::usize,
4362 fmt: *const crate::ffi::c_wchar_t,
4363 ap: crate::ffi::VaList,
4364 ) -> ::core::ffi::c_int;
4365}
4366
4367unsafe extern "C" {
4368 /// This works exactly like asprintf() but doesn't require access to a C
4369 /// runtime.
4370 ///
4371 /// Functions identically to [`SDL_snprintf()`], except it allocates a buffer large
4372 /// enough to hold the output string on behalf of the caller.
4373 ///
4374 /// On success, this function returns the number of bytes (not characters)
4375 /// comprising the output string, not counting the null-terminator character,
4376 /// and sets `*strp` to the newly-allocated string.
4377 ///
4378 /// On error, this function returns a negative number, and the value of `*strp`
4379 /// is undefined.
4380 ///
4381 /// The returned string is owned by the caller, and should be passed to
4382 /// [`SDL_free`] when no longer needed.
4383 ///
4384 /// ## Parameters
4385 /// - `strp`: on output, is set to the new string. Must not be NULL.
4386 /// - `fmt`: a printf-style format string. Must not be NULL.
4387 /// - `...`: a list of values to be used with the format string.
4388 ///
4389 /// ## Return value
4390 /// Returns the number of bytes in the newly-allocated string, not counting
4391 /// the null-terminator char, or a negative value on error.
4392 ///
4393 /// ## Thread safety
4394 /// It is safe to call this function from any thread.
4395 ///
4396 /// ## Availability
4397 /// This function is available since SDL 3.2.0.
4398 pub fn SDL_asprintf(
4399 strp: *mut *mut ::core::ffi::c_char,
4400 fmt: *const ::core::ffi::c_char,
4401 ...
4402 ) -> ::core::ffi::c_int;
4403}
4404
4405unsafe extern "C" {
4406 /// This works exactly like vasprintf() but doesn't require access to a C
4407 /// runtime.
4408 ///
4409 /// Functions identically to [`SDL_asprintf()`], except it takes a `va_list`
4410 /// instead of using `...` variable arguments.
4411 ///
4412 /// ## Parameters
4413 /// - `strp`: on output, is set to the new string. Must not be NULL.
4414 /// - `fmt`: a printf-style format string. Must not be NULL.
4415 /// - `ap`: a `va_list` values to be used with the format string.
4416 ///
4417 /// ## Return value
4418 /// Returns the number of bytes in the newly-allocated string, not counting
4419 /// the null-terminator char, or a negative value on error.
4420 ///
4421 /// ## Thread safety
4422 /// It is safe to call this function from any thread.
4423 ///
4424 /// ## Availability
4425 /// This function is available since SDL 3.2.0.
4426 pub fn SDL_vasprintf(
4427 strp: *mut *mut ::core::ffi::c_char,
4428 fmt: *const ::core::ffi::c_char,
4429 ap: crate::ffi::VaList,
4430 ) -> ::core::ffi::c_int;
4431}
4432
4433unsafe extern "C" {
4434 /// Seeds the pseudo-random number generator.
4435 ///
4436 /// Reusing the seed number will cause [`SDL_rand()`] to repeat the same stream of
4437 /// 'random' numbers.
4438 ///
4439 /// ## Parameters
4440 /// - `seed`: the value to use as a random number seed, or 0 to use
4441 /// [`SDL_GetPerformanceCounter()`].
4442 ///
4443 /// ## Thread safety
4444 /// This should be called on the same thread that calls
4445 /// [`SDL_rand()`]
4446 ///
4447 /// ## Availability
4448 /// This function is available since SDL 3.2.0.
4449 ///
4450 /// ## See also
4451 /// - [`SDL_rand`]
4452 /// - [`SDL_rand_bits`]
4453 /// - [`SDL_randf`]
4454 pub fn SDL_srand(seed: Uint64);
4455}
4456
4457unsafe extern "C" {
4458 /// Generate a pseudo-random number less than n for positive n
4459 ///
4460 /// The method used is faster and of better quality than `rand() % n`. Odds are
4461 /// roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and
4462 /// much worse as n gets bigger.
4463 ///
4464 /// Example: to simulate a d6 use `SDL_rand(6) + 1` The +1 converts 0..5 to
4465 /// 1..6
4466 ///
4467 /// If you want to generate a pseudo-random number in the full range of Sint32,
4468 /// you should use: (Sint32)SDL_rand_bits()
4469 ///
4470 /// If you want reproducible output, be sure to initialize with [`SDL_srand()`]
4471 /// first.
4472 ///
4473 /// There are no guarantees as to the quality of the random sequence produced,
4474 /// and this should not be used for security (cryptography, passwords) or where
4475 /// money is on the line (loot-boxes, casinos). There are many random number
4476 /// libraries available with different characteristics and you should pick one
4477 /// of those to meet any serious needs.
4478 ///
4479 /// ## Parameters
4480 /// - `n`: the number of possible outcomes. n must be positive.
4481 ///
4482 /// ## Return value
4483 /// Returns a random value in the range of \[0 .. n-1\].
4484 ///
4485 /// ## Thread safety
4486 /// All calls should be made from a single thread
4487 ///
4488 /// ## Availability
4489 /// This function is available since SDL 3.2.0.
4490 ///
4491 /// ## See also
4492 /// - [`SDL_srand`]
4493 /// - [`SDL_randf`]
4494 pub fn SDL_rand(n: Sint32) -> Sint32;
4495}
4496
4497unsafe extern "C" {
4498 /// Generate a uniform pseudo-random floating point number less than 1.0
4499 ///
4500 /// If you want reproducible output, be sure to initialize with [`SDL_srand()`]
4501 /// first.
4502 ///
4503 /// There are no guarantees as to the quality of the random sequence produced,
4504 /// and this should not be used for security (cryptography, passwords) or where
4505 /// money is on the line (loot-boxes, casinos). There are many random number
4506 /// libraries available with different characteristics and you should pick one
4507 /// of those to meet any serious needs.
4508 ///
4509 /// ## Return value
4510 /// Returns a random value in the range of [0.0, 1.0).
4511 ///
4512 /// ## Thread safety
4513 /// All calls should be made from a single thread
4514 ///
4515 /// ## Availability
4516 /// This function is available since SDL 3.2.0.
4517 ///
4518 /// ## See also
4519 /// - [`SDL_srand`]
4520 /// - [`SDL_rand`]
4521 pub fn SDL_randf() -> ::core::ffi::c_float;
4522}
4523
4524unsafe extern "C" {
4525 /// Generate 32 pseudo-random bits.
4526 ///
4527 /// You likely want to use [`SDL_rand()`] to get a psuedo-random number instead.
4528 ///
4529 /// There are no guarantees as to the quality of the random sequence produced,
4530 /// and this should not be used for security (cryptography, passwords) or where
4531 /// money is on the line (loot-boxes, casinos). There are many random number
4532 /// libraries available with different characteristics and you should pick one
4533 /// of those to meet any serious needs.
4534 ///
4535 /// ## Return value
4536 /// Returns a random value in the range of \[0-SDL_MAX_UINT32\].
4537 ///
4538 /// ## Thread safety
4539 /// All calls should be made from a single thread
4540 ///
4541 /// ## Availability
4542 /// This function is available since SDL 3.2.0.
4543 ///
4544 /// ## See also
4545 /// - [`SDL_rand`]
4546 /// - [`SDL_randf`]
4547 /// - [`SDL_srand`]
4548 pub fn SDL_rand_bits() -> Uint32;
4549}
4550
4551unsafe extern "C" {
4552 /// Generate a pseudo-random number less than n for positive n
4553 ///
4554 /// The method used is faster and of better quality than `rand() % n`. Odds are
4555 /// roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and
4556 /// much worse as n gets bigger.
4557 ///
4558 /// Example: to simulate a d6 use `SDL_rand_r(state, 6) + 1` The +1 converts
4559 /// 0..5 to 1..6
4560 ///
4561 /// If you want to generate a pseudo-random number in the full range of Sint32,
4562 /// you should use: (Sint32)SDL_rand_bits_r(state)
4563 ///
4564 /// There are no guarantees as to the quality of the random sequence produced,
4565 /// and this should not be used for security (cryptography, passwords) or where
4566 /// money is on the line (loot-boxes, casinos). There are many random number
4567 /// libraries available with different characteristics and you should pick one
4568 /// of those to meet any serious needs.
4569 ///
4570 /// ## Parameters
4571 /// - `state`: a pointer to the current random number state, this may not be
4572 /// NULL.
4573 /// - `n`: the number of possible outcomes. n must be positive.
4574 ///
4575 /// ## Return value
4576 /// Returns a random value in the range of \[0 .. n-1\].
4577 ///
4578 /// ## Thread safety
4579 /// This function is thread-safe, as long as the state pointer
4580 /// isn't shared between threads.
4581 ///
4582 /// ## Availability
4583 /// This function is available since SDL 3.2.0.
4584 ///
4585 /// ## See also
4586 /// - [`SDL_rand`]
4587 /// - [`SDL_rand_bits_r`]
4588 /// - [`SDL_randf_r`]
4589 pub fn SDL_rand_r(state: *mut Uint64, n: Sint32) -> Sint32;
4590}
4591
4592unsafe extern "C" {
4593 /// Generate a uniform pseudo-random floating point number less than 1.0
4594 ///
4595 /// If you want reproducible output, be sure to initialize with [`SDL_srand()`]
4596 /// first.
4597 ///
4598 /// There are no guarantees as to the quality of the random sequence produced,
4599 /// and this should not be used for security (cryptography, passwords) or where
4600 /// money is on the line (loot-boxes, casinos). There are many random number
4601 /// libraries available with different characteristics and you should pick one
4602 /// of those to meet any serious needs.
4603 ///
4604 /// ## Parameters
4605 /// - `state`: a pointer to the current random number state, this may not be
4606 /// NULL.
4607 ///
4608 /// ## Return value
4609 /// Returns a random value in the range of [0.0, 1.0).
4610 ///
4611 /// ## Thread safety
4612 /// This function is thread-safe, as long as the state pointer
4613 /// isn't shared between threads.
4614 ///
4615 /// ## Availability
4616 /// This function is available since SDL 3.2.0.
4617 ///
4618 /// ## See also
4619 /// - [`SDL_rand_bits_r`]
4620 /// - [`SDL_rand_r`]
4621 /// - [`SDL_randf`]
4622 pub fn SDL_randf_r(state: *mut Uint64) -> ::core::ffi::c_float;
4623}
4624
4625unsafe extern "C" {
4626 /// Generate 32 pseudo-random bits.
4627 ///
4628 /// You likely want to use [`SDL_rand_r()`] to get a psuedo-random number instead.
4629 ///
4630 /// There are no guarantees as to the quality of the random sequence produced,
4631 /// and this should not be used for security (cryptography, passwords) or where
4632 /// money is on the line (loot-boxes, casinos). There are many random number
4633 /// libraries available with different characteristics and you should pick one
4634 /// of those to meet any serious needs.
4635 ///
4636 /// ## Parameters
4637 /// - `state`: a pointer to the current random number state, this may not be
4638 /// NULL.
4639 ///
4640 /// ## Return value
4641 /// Returns a random value in the range of \[0-SDL_MAX_UINT32\].
4642 ///
4643 /// ## Thread safety
4644 /// This function is thread-safe, as long as the state pointer
4645 /// isn't shared between threads.
4646 ///
4647 /// ## Availability
4648 /// This function is available since SDL 3.2.0.
4649 ///
4650 /// ## See also
4651 /// - [`SDL_rand_r`]
4652 /// - [`SDL_randf_r`]
4653 pub fn SDL_rand_bits_r(state: *mut Uint64) -> Uint32;
4654}
4655
4656/// The value of Pi, as a double-precision floating point literal.
4657///
4658/// ## Availability
4659/// This macro is available since SDL 3.2.0.
4660///
4661/// ## See also
4662/// - [`SDL_PI_F`]
4663pub const SDL_PI_D: ::core::ffi::c_double = 3.141592653589793_f64;
4664
4665/// The value of Pi, as a single-precision floating point literal.
4666///
4667/// ## Availability
4668/// This macro is available since SDL 3.2.0.
4669///
4670/// ## See also
4671/// - [`SDL_PI_D`]
4672pub const SDL_PI_F: ::core::ffi::c_float = 3.1415927_f32;
4673
4674unsafe extern "C" {
4675 /// Compute the arc cosine of `x`.
4676 ///
4677 /// The definition of `y = acos(x)` is `x = cos(y)`.
4678 ///
4679 /// Domain: `-1 <= x <= 1`
4680 ///
4681 /// Range: `0 <= y <= Pi`
4682 ///
4683 /// This function operates on double-precision floating point values, use
4684 /// [`SDL_acosf`] for single-precision floats.
4685 ///
4686 /// This function may use a different approximation across different versions,
4687 /// platforms and configurations. i.e, it can return a different value given
4688 /// the same input on different machines or operating systems, or if SDL is
4689 /// updated.
4690 ///
4691 /// ## Parameters
4692 /// - `x`: floating point value.
4693 ///
4694 /// ## Return value
4695 /// Returns arc cosine of `x`, in radians.
4696 ///
4697 /// ## Thread safety
4698 /// It is safe to call this function from any thread.
4699 ///
4700 /// ## Availability
4701 /// This function is available since SDL 3.2.0.
4702 ///
4703 /// ## See also
4704 /// - [`SDL_acosf`]
4705 /// - [`SDL_asin`]
4706 /// - [`SDL_cos`]
4707 pub safe fn SDL_acos(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
4708}
4709
4710unsafe extern "C" {
4711 /// Compute the arc cosine of `x`.
4712 ///
4713 /// The definition of `y = acos(x)` is `x = cos(y)`.
4714 ///
4715 /// Domain: `-1 <= x <= 1`
4716 ///
4717 /// Range: `0 <= y <= Pi`
4718 ///
4719 /// This function operates on single-precision floating point values, use
4720 /// [`SDL_acos`] for double-precision floats.
4721 ///
4722 /// This function may use a different approximation across different versions,
4723 /// platforms and configurations. i.e, it can return a different value given
4724 /// the same input on different machines or operating systems, or if SDL is
4725 /// updated.
4726 ///
4727 /// ## Parameters
4728 /// - `x`: floating point value.
4729 ///
4730 /// ## Return value
4731 /// Returns arc cosine of `x`, in radians.
4732 ///
4733 /// ## Thread safety
4734 /// It is safe to call this function from any thread.
4735 ///
4736 /// ## Availability
4737 /// This function is available since SDL 3.2.0.
4738 ///
4739 /// ## See also
4740 /// - [`SDL_acos`]
4741 /// - [`SDL_asinf`]
4742 /// - [`SDL_cosf`]
4743 pub safe fn SDL_acosf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
4744}
4745
4746unsafe extern "C" {
4747 /// Compute the arc sine of `x`.
4748 ///
4749 /// The definition of `y = asin(x)` is `x = sin(y)`.
4750 ///
4751 /// Domain: `-1 <= x <= 1`
4752 ///
4753 /// Range: `-Pi/2 <= y <= Pi/2`
4754 ///
4755 /// This function operates on double-precision floating point values, use
4756 /// [`SDL_asinf`] for single-precision floats.
4757 ///
4758 /// This function may use a different approximation across different versions,
4759 /// platforms and configurations. i.e, it can return a different value given
4760 /// the same input on different machines or operating systems, or if SDL is
4761 /// updated.
4762 ///
4763 /// ## Parameters
4764 /// - `x`: floating point value.
4765 ///
4766 /// ## Return value
4767 /// Returns arc sine of `x`, in radians.
4768 ///
4769 /// ## Thread safety
4770 /// It is safe to call this function from any thread.
4771 ///
4772 /// ## Availability
4773 /// This function is available since SDL 3.2.0.
4774 ///
4775 /// ## See also
4776 /// - [`SDL_asinf`]
4777 /// - [`SDL_acos`]
4778 /// - [`SDL_sin`]
4779 pub safe fn SDL_asin(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
4780}
4781
4782unsafe extern "C" {
4783 /// Compute the arc sine of `x`.
4784 ///
4785 /// The definition of `y = asin(x)` is `x = sin(y)`.
4786 ///
4787 /// Domain: `-1 <= x <= 1`
4788 ///
4789 /// Range: `-Pi/2 <= y <= Pi/2`
4790 ///
4791 /// This function operates on single-precision floating point values, use
4792 /// [`SDL_asin`] for double-precision floats.
4793 ///
4794 /// This function may use a different approximation across different versions,
4795 /// platforms and configurations. i.e, it can return a different value given
4796 /// the same input on different machines or operating systems, or if SDL is
4797 /// updated.
4798 ///
4799 /// ## Parameters
4800 /// - `x`: floating point value.
4801 ///
4802 /// ## Return value
4803 /// Returns arc sine of `x`, in radians.
4804 ///
4805 /// ## Thread safety
4806 /// It is safe to call this function from any thread.
4807 ///
4808 /// ## Availability
4809 /// This function is available since SDL 3.2.0.
4810 ///
4811 /// ## See also
4812 /// - [`SDL_asin`]
4813 /// - [`SDL_acosf`]
4814 /// - [`SDL_sinf`]
4815 pub safe fn SDL_asinf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
4816}
4817
4818unsafe extern "C" {
4819 /// Compute the arc tangent of `x`.
4820 ///
4821 /// The definition of `y = atan(x)` is `x = tan(y)`.
4822 ///
4823 /// Domain: `-INF <= x <= INF`
4824 ///
4825 /// Range: `-Pi/2 <= y <= Pi/2`
4826 ///
4827 /// This function operates on double-precision floating point values, use
4828 /// [`SDL_atanf`] for single-precision floats.
4829 ///
4830 /// To calculate the arc tangent of y / x, use [`SDL_atan2`].
4831 ///
4832 /// This function may use a different approximation across different versions,
4833 /// platforms and configurations. i.e, it can return a different value given
4834 /// the same input on different machines or operating systems, or if SDL is
4835 /// updated.
4836 ///
4837 /// ## Parameters
4838 /// - `x`: floating point value.
4839 ///
4840 /// ## Return value
4841 /// Returns arc tangent of of `x` in radians, or 0 if `x = 0`.
4842 ///
4843 /// ## Thread safety
4844 /// It is safe to call this function from any thread.
4845 ///
4846 /// ## Availability
4847 /// This function is available since SDL 3.2.0.
4848 ///
4849 /// ## See also
4850 /// - [`SDL_atanf`]
4851 /// - [`SDL_atan2`]
4852 /// - [`SDL_tan`]
4853 pub safe fn SDL_atan(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
4854}
4855
4856unsafe extern "C" {
4857 /// Compute the arc tangent of `x`.
4858 ///
4859 /// The definition of `y = atan(x)` is `x = tan(y)`.
4860 ///
4861 /// Domain: `-INF <= x <= INF`
4862 ///
4863 /// Range: `-Pi/2 <= y <= Pi/2`
4864 ///
4865 /// This function operates on single-precision floating point values, use
4866 /// [`SDL_atan`] for dboule-precision floats.
4867 ///
4868 /// To calculate the arc tangent of y / x, use [`SDL_atan2f`].
4869 ///
4870 /// This function may use a different approximation across different versions,
4871 /// platforms and configurations. i.e, it can return a different value given
4872 /// the same input on different machines or operating systems, or if SDL is
4873 /// updated.
4874 ///
4875 /// ## Parameters
4876 /// - `x`: floating point value.
4877 ///
4878 /// ## Return value
4879 /// Returns arc tangent of of `x` in radians, or 0 if `x = 0`.
4880 ///
4881 /// ## Thread safety
4882 /// It is safe to call this function from any thread.
4883 ///
4884 /// ## Availability
4885 /// This function is available since SDL 3.2.0.
4886 ///
4887 /// ## See also
4888 /// - [`SDL_atan`]
4889 /// - [`SDL_atan2f`]
4890 /// - [`SDL_tanf`]
4891 pub safe fn SDL_atanf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
4892}
4893
4894unsafe extern "C" {
4895 /// Compute the arc tangent of `y / x`, using the signs of x and y to adjust
4896 /// the result's quadrant.
4897 ///
4898 /// The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant
4899 /// of z is determined based on the signs of x and y.
4900 ///
4901 /// Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
4902 ///
4903 /// Range: `-Pi <= y <= Pi`
4904 ///
4905 /// This function operates on double-precision floating point values, use
4906 /// [`SDL_atan2f`] for single-precision floats.
4907 ///
4908 /// To calculate the arc tangent of a single value, use [`SDL_atan`].
4909 ///
4910 /// This function may use a different approximation across different versions,
4911 /// platforms and configurations. i.e, it can return a different value given
4912 /// the same input on different machines or operating systems, or if SDL is
4913 /// updated.
4914 ///
4915 /// ## Parameters
4916 /// - `y`: floating point value of the numerator (y coordinate).
4917 /// - `x`: floating point value of the denominator (x coordinate).
4918 ///
4919 /// ## Return value
4920 /// Returns arc tangent of of `y / x` in radians, or, if `x = 0`, either
4921 /// `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`.
4922 ///
4923 /// ## Thread safety
4924 /// It is safe to call this function from any thread.
4925 ///
4926 /// ## Availability
4927 /// This function is available since SDL 3.2.0.
4928 ///
4929 /// ## See also
4930 /// - [`SDL_atan2f`]
4931 /// - [`SDL_atan`]
4932 /// - [`SDL_tan`]
4933 pub safe fn SDL_atan2(
4934 y: ::core::ffi::c_double,
4935 x: ::core::ffi::c_double,
4936 ) -> ::core::ffi::c_double;
4937}
4938
4939unsafe extern "C" {
4940 /// Compute the arc tangent of `y / x`, using the signs of x and y to adjust
4941 /// the result's quadrant.
4942 ///
4943 /// The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant
4944 /// of z is determined based on the signs of x and y.
4945 ///
4946 /// Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
4947 ///
4948 /// Range: `-Pi <= y <= Pi`
4949 ///
4950 /// This function operates on single-precision floating point values, use
4951 /// [`SDL_atan2`] for double-precision floats.
4952 ///
4953 /// To calculate the arc tangent of a single value, use [`SDL_atanf`].
4954 ///
4955 /// This function may use a different approximation across different versions,
4956 /// platforms and configurations. i.e, it can return a different value given
4957 /// the same input on different machines or operating systems, or if SDL is
4958 /// updated.
4959 ///
4960 /// ## Parameters
4961 /// - `y`: floating point value of the numerator (y coordinate).
4962 /// - `x`: floating point value of the denominator (x coordinate).
4963 ///
4964 /// ## Return value
4965 /// Returns arc tangent of of `y / x` in radians, or, if `x = 0`, either
4966 /// `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`.
4967 ///
4968 /// ## Thread safety
4969 /// It is safe to call this function from any thread.
4970 ///
4971 /// ## Availability
4972 /// This function is available since SDL 3.2.0.
4973 ///
4974 /// ## See also
4975 /// - [`SDL_atan2`]
4976 /// - [`SDL_atan`]
4977 /// - [`SDL_tan`]
4978 pub safe fn SDL_atan2f(
4979 y: ::core::ffi::c_float,
4980 x: ::core::ffi::c_float,
4981 ) -> ::core::ffi::c_float;
4982}
4983
4984unsafe extern "C" {
4985 /// Compute the ceiling of `x`.
4986 ///
4987 /// The ceiling of `x` is the smallest integer `y` such that `y >= x`, i.e `x`
4988 /// rounded up to the nearest integer.
4989 ///
4990 /// Domain: `-INF <= x <= INF`
4991 ///
4992 /// Range: `-INF <= y <= INF`, y integer
4993 ///
4994 /// This function operates on double-precision floating point values, use
4995 /// [`SDL_ceilf`] for single-precision floats.
4996 ///
4997 /// ## Parameters
4998 /// - `x`: floating point value.
4999 ///
5000 /// ## Return value
5001 /// Returns the ceiling of `x`.
5002 ///
5003 /// ## Thread safety
5004 /// It is safe to call this function from any thread.
5005 ///
5006 /// ## Availability
5007 /// This function is available since SDL 3.2.0.
5008 ///
5009 /// ## See also
5010 /// - [`SDL_ceilf`]
5011 /// - [`SDL_floor`]
5012 /// - [`SDL_trunc`]
5013 /// - [`SDL_round`]
5014 /// - [`SDL_lround`]
5015 pub safe fn SDL_ceil(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
5016}
5017
5018unsafe extern "C" {
5019 /// Compute the ceiling of `x`.
5020 ///
5021 /// The ceiling of `x` is the smallest integer `y` such that `y >= x`, i.e `x`
5022 /// rounded up to the nearest integer.
5023 ///
5024 /// Domain: `-INF <= x <= INF`
5025 ///
5026 /// Range: `-INF <= y <= INF`, y integer
5027 ///
5028 /// This function operates on single-precision floating point values, use
5029 /// [`SDL_ceil`] for double-precision floats.
5030 ///
5031 /// ## Parameters
5032 /// - `x`: floating point value.
5033 ///
5034 /// ## Return value
5035 /// Returns the ceiling of `x`.
5036 ///
5037 /// ## Thread safety
5038 /// It is safe to call this function from any thread.
5039 ///
5040 /// ## Availability
5041 /// This function is available since SDL 3.2.0.
5042 ///
5043 /// ## See also
5044 /// - [`SDL_ceil`]
5045 /// - [`SDL_floorf`]
5046 /// - [`SDL_truncf`]
5047 /// - [`SDL_roundf`]
5048 /// - [`SDL_lroundf`]
5049 pub safe fn SDL_ceilf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
5050}
5051
5052/// Copy the sign of one floating-point value to another.
5053///
5054/// The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``.
5055///
5056/// Domain: `-INF <= x <= INF`, ``-INF <= y <= f``
5057///
5058/// Range: `-INF <= z <= INF`
5059///
5060/// This function operates on double-precision floating point values, use
5061/// [`SDL_copysignf`] for single-precision floats.
5062///
5063/// ## Parameters
5064/// - `x`: floating point value to use as the magnitude.
5065/// - `y`: floating point value to use as the sign.
5066///
5067/// ## Return value
5068/// Returns the floating point value with the sign of y and the magnitude of
5069/// x.
5070///
5071/// ## Thread safety
5072/// It is safe to call this function from any thread.
5073///
5074/// ## Availability
5075/// This function is available since SDL 3.2.0.
5076///
5077/// ## See also
5078/// - [`SDL_copysignf`]
5079/// - [`SDL_fabs`]
5080#[inline(always)]
5081pub const fn SDL_copysign(
5082 x: ::core::ffi::c_double,
5083 y: ::core::ffi::c_double,
5084) -> ::core::ffi::c_double {
5085 return x.copysign(y);
5086}
5087
5088/// Copy the sign of one floating-point value to another.
5089///
5090/// The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``.
5091///
5092/// Domain: `-INF <= x <= INF`, ``-INF <= y <= f``
5093///
5094/// Range: `-INF <= z <= INF`
5095///
5096/// This function operates on single-precision floating point values, use
5097/// [`SDL_copysign`] for double-precision floats.
5098///
5099/// ## Parameters
5100/// - `x`: floating point value to use as the magnitude.
5101/// - `y`: floating point value to use as the sign.
5102///
5103/// ## Return value
5104/// Returns the floating point value with the sign of y and the magnitude of
5105/// x.
5106///
5107/// ## Thread safety
5108/// It is safe to call this function from any thread.
5109///
5110/// ## Availability
5111/// This function is available since SDL 3.2.0.
5112///
5113/// ## See also
5114/// - [`SDL_copysign`]
5115/// - [`SDL_fabsf`]
5116#[inline(always)]
5117pub const fn SDL_copysignf(
5118 x: ::core::ffi::c_float,
5119 y: ::core::ffi::c_float,
5120) -> ::core::ffi::c_float {
5121 return x.copysign(y);
5122}
5123
5124unsafe extern "C" {
5125 /// Compute the cosine of `x`.
5126 ///
5127 /// Domain: `-INF <= x <= INF`
5128 ///
5129 /// Range: `-1 <= y <= 1`
5130 ///
5131 /// This function operates on double-precision floating point values, use
5132 /// [`SDL_cosf`] for single-precision floats.
5133 ///
5134 /// This function may use a different approximation across different versions,
5135 /// platforms and configurations. i.e, it can return a different value given
5136 /// the same input on different machines or operating systems, or if SDL is
5137 /// updated.
5138 ///
5139 /// ## Parameters
5140 /// - `x`: floating point value, in radians.
5141 ///
5142 /// ## Return value
5143 /// Returns cosine of `x`.
5144 ///
5145 /// ## Thread safety
5146 /// It is safe to call this function from any thread.
5147 ///
5148 /// ## Availability
5149 /// This function is available since SDL 3.2.0.
5150 ///
5151 /// ## See also
5152 /// - [`SDL_cosf`]
5153 /// - [`SDL_acos`]
5154 /// - [`SDL_sin`]
5155 pub safe fn SDL_cos(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
5156}
5157
5158unsafe extern "C" {
5159 /// Compute the cosine of `x`.
5160 ///
5161 /// Domain: `-INF <= x <= INF`
5162 ///
5163 /// Range: `-1 <= y <= 1`
5164 ///
5165 /// This function operates on single-precision floating point values, use
5166 /// [`SDL_cos`] for double-precision floats.
5167 ///
5168 /// This function may use a different approximation across different versions,
5169 /// platforms and configurations. i.e, it can return a different value given
5170 /// the same input on different machines or operating systems, or if SDL is
5171 /// updated.
5172 ///
5173 /// ## Parameters
5174 /// - `x`: floating point value, in radians.
5175 ///
5176 /// ## Return value
5177 /// Returns cosine of `x`.
5178 ///
5179 /// ## Thread safety
5180 /// It is safe to call this function from any thread.
5181 ///
5182 /// ## Availability
5183 /// This function is available since SDL 3.2.0.
5184 ///
5185 /// ## See also
5186 /// - [`SDL_cos`]
5187 /// - [`SDL_acosf`]
5188 /// - [`SDL_sinf`]
5189 pub safe fn SDL_cosf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
5190}
5191
5192unsafe extern "C" {
5193 /// Compute the exponential of `x`.
5194 ///
5195 /// The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the
5196 /// natural logarithm. The inverse is the natural logarithm, [`SDL_log`].
5197 ///
5198 /// Domain: `-INF <= x <= INF`
5199 ///
5200 /// Range: `0 <= y <= INF`
5201 ///
5202 /// The output will overflow if `exp(x)` is too large to be represented.
5203 ///
5204 /// This function operates on double-precision floating point values, use
5205 /// [`SDL_expf`] for single-precision floats.
5206 ///
5207 /// This function may use a different approximation across different versions,
5208 /// platforms and configurations. i.e, it can return a different value given
5209 /// the same input on different machines or operating systems, or if SDL is
5210 /// updated.
5211 ///
5212 /// ## Parameters
5213 /// - `x`: floating point value.
5214 ///
5215 /// ## Return value
5216 /// Returns value of `e^x`.
5217 ///
5218 /// ## Thread safety
5219 /// It is safe to call this function from any thread.
5220 ///
5221 /// ## Availability
5222 /// This function is available since SDL 3.2.0.
5223 ///
5224 /// ## See also
5225 /// - [`SDL_expf`]
5226 /// - [`SDL_log`]
5227 pub safe fn SDL_exp(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
5228}
5229
5230unsafe extern "C" {
5231 /// Compute the exponential of `x`.
5232 ///
5233 /// The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the
5234 /// natural logarithm. The inverse is the natural logarithm, [`SDL_logf`].
5235 ///
5236 /// Domain: `-INF <= x <= INF`
5237 ///
5238 /// Range: `0 <= y <= INF`
5239 ///
5240 /// The output will overflow if `exp(x)` is too large to be represented.
5241 ///
5242 /// This function operates on single-precision floating point values, use
5243 /// [`SDL_exp`] for double-precision floats.
5244 ///
5245 /// This function may use a different approximation across different versions,
5246 /// platforms and configurations. i.e, it can return a different value given
5247 /// the same input on different machines or operating systems, or if SDL is
5248 /// updated.
5249 ///
5250 /// ## Parameters
5251 /// - `x`: floating point value.
5252 ///
5253 /// ## Return value
5254 /// Returns value of `e^x`.
5255 ///
5256 /// ## Thread safety
5257 /// It is safe to call this function from any thread.
5258 ///
5259 /// ## Availability
5260 /// This function is available since SDL 3.2.0.
5261 ///
5262 /// ## See also
5263 /// - [`SDL_exp`]
5264 /// - [`SDL_logf`]
5265 pub safe fn SDL_expf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
5266}
5267
5268/// Compute the absolute value of `x`
5269///
5270/// Domain: `-INF <= x <= INF`
5271///
5272/// Range: `0 <= y <= INF`
5273///
5274/// This function operates on double-precision floating point values, use
5275/// [`SDL_fabsf`] for single-precision floats.
5276///
5277/// ## Parameters
5278/// - `x`: floating point value to use as the magnitude.
5279///
5280/// ## Return value
5281/// Returns the absolute value of `x`.
5282///
5283/// ## Thread safety
5284/// It is safe to call this function from any thread.
5285///
5286/// ## Availability
5287/// This function is available since SDL 3.2.0.
5288///
5289/// ## See also
5290/// - [`SDL_fabsf`]
5291#[inline(always)]
5292pub const fn SDL_fabs(x: ::core::ffi::c_double) -> ::core::ffi::c_double {
5293 return x.abs();
5294}
5295
5296/// Compute the absolute value of `x`
5297///
5298/// Domain: `-INF <= x <= INF`
5299///
5300/// Range: `0 <= y <= INF`
5301///
5302/// This function operates on single-precision floating point values, use
5303/// [`SDL_fabs`] for double-precision floats.
5304///
5305/// ## Parameters
5306/// - `x`: floating point value to use as the magnitude.
5307///
5308/// ## Return value
5309/// Returns the absolute value of `x`.
5310///
5311/// ## Thread safety
5312/// It is safe to call this function from any thread.
5313///
5314/// ## Availability
5315/// This function is available since SDL 3.2.0.
5316///
5317/// ## See also
5318/// - [`SDL_fabs`]
5319#[inline(always)]
5320pub const fn SDL_fabsf(x: ::core::ffi::c_float) -> ::core::ffi::c_float {
5321 return x.abs();
5322}
5323
5324unsafe extern "C" {
5325 /// Compute the floor of `x`.
5326 ///
5327 /// The floor of `x` is the largest integer `y` such that `y <= x`, i.e `x`
5328 /// rounded down to the nearest integer.
5329 ///
5330 /// Domain: `-INF <= x <= INF`
5331 ///
5332 /// Range: `-INF <= y <= INF`, y integer
5333 ///
5334 /// This function operates on double-precision floating point values, use
5335 /// [`SDL_floorf`] for single-precision floats.
5336 ///
5337 /// ## Parameters
5338 /// - `x`: floating point value.
5339 ///
5340 /// ## Return value
5341 /// Returns the floor of `x`.
5342 ///
5343 /// ## Thread safety
5344 /// It is safe to call this function from any thread.
5345 ///
5346 /// ## Availability
5347 /// This function is available since SDL 3.2.0.
5348 ///
5349 /// ## See also
5350 /// - [`SDL_floorf`]
5351 /// - [`SDL_ceil`]
5352 /// - [`SDL_trunc`]
5353 /// - [`SDL_round`]
5354 /// - [`SDL_lround`]
5355 pub safe fn SDL_floor(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
5356}
5357
5358unsafe extern "C" {
5359 /// Compute the floor of `x`.
5360 ///
5361 /// The floor of `x` is the largest integer `y` such that `y <= x`, i.e `x`
5362 /// rounded down to the nearest integer.
5363 ///
5364 /// Domain: `-INF <= x <= INF`
5365 ///
5366 /// Range: `-INF <= y <= INF`, y integer
5367 ///
5368 /// This function operates on single-precision floating point values, use
5369 /// [`SDL_floor`] for double-precision floats.
5370 ///
5371 /// ## Parameters
5372 /// - `x`: floating point value.
5373 ///
5374 /// ## Return value
5375 /// Returns the floor of `x`.
5376 ///
5377 /// ## Thread safety
5378 /// It is safe to call this function from any thread.
5379 ///
5380 /// ## Availability
5381 /// This function is available since SDL 3.2.0.
5382 ///
5383 /// ## See also
5384 /// - [`SDL_floor`]
5385 /// - [`SDL_ceilf`]
5386 /// - [`SDL_truncf`]
5387 /// - [`SDL_roundf`]
5388 /// - [`SDL_lroundf`]
5389 pub safe fn SDL_floorf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
5390}
5391
5392unsafe extern "C" {
5393 /// Truncate `x` to an integer.
5394 ///
5395 /// Rounds `x` to the next closest integer to 0. This is equivalent to removing
5396 /// the fractional part of `x`, leaving only the integer part.
5397 ///
5398 /// Domain: `-INF <= x <= INF`
5399 ///
5400 /// Range: `-INF <= y <= INF`, y integer
5401 ///
5402 /// This function operates on double-precision floating point values, use
5403 /// [`SDL_truncf`] for single-precision floats.
5404 ///
5405 /// ## Parameters
5406 /// - `x`: floating point value.
5407 ///
5408 /// ## Return value
5409 /// Returns `x` truncated to an integer.
5410 ///
5411 /// ## Thread safety
5412 /// It is safe to call this function from any thread.
5413 ///
5414 /// ## Availability
5415 /// This function is available since SDL 3.2.0.
5416 ///
5417 /// ## See also
5418 /// - [`SDL_truncf`]
5419 /// - [`SDL_fmod`]
5420 /// - [`SDL_ceil`]
5421 /// - [`SDL_floor`]
5422 /// - [`SDL_round`]
5423 /// - [`SDL_lround`]
5424 pub safe fn SDL_trunc(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
5425}
5426
5427unsafe extern "C" {
5428 /// Truncate `x` to an integer.
5429 ///
5430 /// Rounds `x` to the next closest integer to 0. This is equivalent to removing
5431 /// the fractional part of `x`, leaving only the integer part.
5432 ///
5433 /// Domain: `-INF <= x <= INF`
5434 ///
5435 /// Range: `-INF <= y <= INF`, y integer
5436 ///
5437 /// This function operates on single-precision floating point values, use
5438 /// [`SDL_trunc`] for double-precision floats.
5439 ///
5440 /// ## Parameters
5441 /// - `x`: floating point value.
5442 ///
5443 /// ## Return value
5444 /// Returns `x` truncated to an integer.
5445 ///
5446 /// ## Thread safety
5447 /// It is safe to call this function from any thread.
5448 ///
5449 /// ## Availability
5450 /// This function is available since SDL 3.2.0.
5451 ///
5452 /// ## See also
5453 /// - [`SDL_trunc`]
5454 /// - [`SDL_fmodf`]
5455 /// - [`SDL_ceilf`]
5456 /// - [`SDL_floorf`]
5457 /// - [`SDL_roundf`]
5458 /// - [`SDL_lroundf`]
5459 pub safe fn SDL_truncf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
5460}
5461
5462unsafe extern "C" {
5463 /// Return the floating-point remainder of `x / y`
5464 ///
5465 /// Divides `x` by `y`, and returns the remainder.
5466 ///
5467 /// Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0`
5468 ///
5469 /// Range: `-y <= z <= y`
5470 ///
5471 /// This function operates on double-precision floating point values, use
5472 /// [`SDL_fmodf`] for single-precision floats.
5473 ///
5474 /// ## Parameters
5475 /// - `x`: the numerator.
5476 /// - `y`: the denominator. Must not be 0.
5477 ///
5478 /// ## Return value
5479 /// Returns the remainder of `x / y`.
5480 ///
5481 /// ## Thread safety
5482 /// It is safe to call this function from any thread.
5483 ///
5484 /// ## Availability
5485 /// This function is available since SDL 3.2.0.
5486 ///
5487 /// ## See also
5488 /// - [`SDL_fmodf`]
5489 /// - [`SDL_modf`]
5490 /// - [`SDL_trunc`]
5491 /// - [`SDL_ceil`]
5492 /// - [`SDL_floor`]
5493 /// - [`SDL_round`]
5494 /// - [`SDL_lround`]
5495 pub safe fn SDL_fmod(
5496 x: ::core::ffi::c_double,
5497 y: ::core::ffi::c_double,
5498 ) -> ::core::ffi::c_double;
5499}
5500
5501unsafe extern "C" {
5502 /// Return the floating-point remainder of `x / y`
5503 ///
5504 /// Divides `x` by `y`, and returns the remainder.
5505 ///
5506 /// Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0`
5507 ///
5508 /// Range: `-y <= z <= y`
5509 ///
5510 /// This function operates on single-precision floating point values, use
5511 /// [`SDL_fmod`] for double-precision floats.
5512 ///
5513 /// ## Parameters
5514 /// - `x`: the numerator.
5515 /// - `y`: the denominator. Must not be 0.
5516 ///
5517 /// ## Return value
5518 /// Returns the remainder of `x / y`.
5519 ///
5520 /// ## Thread safety
5521 /// It is safe to call this function from any thread.
5522 ///
5523 /// ## Availability
5524 /// This function is available since SDL 3.2.0.
5525 ///
5526 /// ## See also
5527 /// - [`SDL_fmod`]
5528 /// - [`SDL_truncf`]
5529 /// - [`SDL_modff`]
5530 /// - [`SDL_ceilf`]
5531 /// - [`SDL_floorf`]
5532 /// - [`SDL_roundf`]
5533 /// - [`SDL_lroundf`]
5534 pub safe fn SDL_fmodf(x: ::core::ffi::c_float, y: ::core::ffi::c_float)
5535 -> ::core::ffi::c_float;
5536}
5537
5538/// Return whether the value is infinity.
5539///
5540/// ## Parameters
5541/// - `x`: double-precision floating point value.
5542///
5543/// ## Return value
5544/// Returns non-zero if the value is infinity, 0 otherwise.
5545///
5546/// ## Thread safety
5547/// It is safe to call this function from any thread.
5548///
5549/// ## Availability
5550/// This function is available since SDL 3.2.0.
5551///
5552/// ## See also
5553/// - [`SDL_isinff`]
5554#[inline(always)]
5555pub const fn SDL_isinf(x: ::core::ffi::c_double) -> ::core::ffi::c_int {
5556 return x.is_infinite() as _;
5557}
5558
5559/// Return whether the value is infinity.
5560///
5561/// ## Parameters
5562/// - `x`: floating point value.
5563///
5564/// ## Return value
5565/// Returns non-zero if the value is infinity, 0 otherwise.
5566///
5567/// ## Thread safety
5568/// It is safe to call this function from any thread.
5569///
5570/// ## Availability
5571/// This function is available since SDL 3.2.0.
5572///
5573/// ## See also
5574/// - [`SDL_isinf`]
5575#[inline(always)]
5576pub const fn SDL_isinff(x: ::core::ffi::c_float) -> ::core::ffi::c_int {
5577 return x.is_infinite() as _;
5578}
5579
5580/// Return whether the value is NaN.
5581///
5582/// ## Parameters
5583/// - `x`: double-precision floating point value.
5584///
5585/// ## Return value
5586/// Returns non-zero if the value is NaN, 0 otherwise.
5587///
5588/// ## Thread safety
5589/// It is safe to call this function from any thread.
5590///
5591/// ## Availability
5592/// This function is available since SDL 3.2.0.
5593///
5594/// ## See also
5595/// - [`SDL_isnanf`]
5596#[inline(always)]
5597pub const fn SDL_isnan(x: ::core::ffi::c_double) -> ::core::ffi::c_int {
5598 return x.is_nan() as _;
5599}
5600
5601/// Return whether the value is NaN.
5602///
5603/// ## Parameters
5604/// - `x`: floating point value.
5605///
5606/// ## Return value
5607/// Returns non-zero if the value is NaN, 0 otherwise.
5608///
5609/// ## Thread safety
5610/// It is safe to call this function from any thread.
5611///
5612/// ## Availability
5613/// This function is available since SDL 3.2.0.
5614///
5615/// ## See also
5616/// - [`SDL_isnan`]
5617#[inline(always)]
5618pub const fn SDL_isnanf(x: ::core::ffi::c_float) -> ::core::ffi::c_int {
5619 return x.is_nan() as _;
5620}
5621
5622unsafe extern "C" {
5623 /// Compute the natural logarithm of `x`.
5624 ///
5625 /// Domain: `0 < x <= INF`
5626 ///
5627 /// Range: `-INF <= y <= INF`
5628 ///
5629 /// It is an error for `x` to be less than or equal to 0.
5630 ///
5631 /// This function operates on double-precision floating point values, use
5632 /// [`SDL_logf`] for single-precision floats.
5633 ///
5634 /// This function may use a different approximation across different versions,
5635 /// platforms and configurations. i.e, it can return a different value given
5636 /// the same input on different machines or operating systems, or if SDL is
5637 /// updated.
5638 ///
5639 /// ## Parameters
5640 /// - `x`: floating point value. Must be greater than 0.
5641 ///
5642 /// ## Return value
5643 /// Returns the natural logarithm of `x`.
5644 ///
5645 /// ## Thread safety
5646 /// It is safe to call this function from any thread.
5647 ///
5648 /// ## Availability
5649 /// This function is available since SDL 3.2.0.
5650 ///
5651 /// ## See also
5652 /// - [`SDL_logf`]
5653 /// - [`SDL_log10`]
5654 /// - [`SDL_exp`]
5655 pub safe fn SDL_log(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
5656}
5657
5658unsafe extern "C" {
5659 /// Compute the natural logarithm of `x`.
5660 ///
5661 /// Domain: `0 < x <= INF`
5662 ///
5663 /// Range: `-INF <= y <= INF`
5664 ///
5665 /// It is an error for `x` to be less than or equal to 0.
5666 ///
5667 /// This function operates on single-precision floating point values, use
5668 /// [`SDL_log`] for double-precision floats.
5669 ///
5670 /// This function may use a different approximation across different versions,
5671 /// platforms and configurations. i.e, it can return a different value given
5672 /// the same input on different machines or operating systems, or if SDL is
5673 /// updated.
5674 ///
5675 /// ## Parameters
5676 /// - `x`: floating point value. Must be greater than 0.
5677 ///
5678 /// ## Return value
5679 /// Returns the natural logarithm of `x`.
5680 ///
5681 /// ## Thread safety
5682 /// It is safe to call this function from any thread.
5683 ///
5684 /// ## Availability
5685 /// This function is available since SDL 3.2.0.
5686 ///
5687 /// ## See also
5688 /// - [`SDL_log`]
5689 /// - [`SDL_expf`]
5690 pub safe fn SDL_logf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
5691}
5692
5693unsafe extern "C" {
5694 /// Compute the base-10 logarithm of `x`.
5695 ///
5696 /// Domain: `0 < x <= INF`
5697 ///
5698 /// Range: `-INF <= y <= INF`
5699 ///
5700 /// It is an error for `x` to be less than or equal to 0.
5701 ///
5702 /// This function operates on double-precision floating point values, use
5703 /// [`SDL_log10f`] for single-precision floats.
5704 ///
5705 /// This function may use a different approximation across different versions,
5706 /// platforms and configurations. i.e, it can return a different value given
5707 /// the same input on different machines or operating systems, or if SDL is
5708 /// updated.
5709 ///
5710 /// ## Parameters
5711 /// - `x`: floating point value. Must be greater than 0.
5712 ///
5713 /// ## Return value
5714 /// Returns the logarithm of `x`.
5715 ///
5716 /// ## Thread safety
5717 /// It is safe to call this function from any thread.
5718 ///
5719 /// ## Availability
5720 /// This function is available since SDL 3.2.0.
5721 ///
5722 /// ## See also
5723 /// - [`SDL_log10f`]
5724 /// - [`SDL_log`]
5725 /// - [`SDL_pow`]
5726 pub safe fn SDL_log10(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
5727}
5728
5729unsafe extern "C" {
5730 /// Compute the base-10 logarithm of `x`.
5731 ///
5732 /// Domain: `0 < x <= INF`
5733 ///
5734 /// Range: `-INF <= y <= INF`
5735 ///
5736 /// It is an error for `x` to be less than or equal to 0.
5737 ///
5738 /// This function operates on single-precision floating point values, use
5739 /// [`SDL_log10`] for double-precision floats.
5740 ///
5741 /// This function may use a different approximation across different versions,
5742 /// platforms and configurations. i.e, it can return a different value given
5743 /// the same input on different machines or operating systems, or if SDL is
5744 /// updated.
5745 ///
5746 /// ## Parameters
5747 /// - `x`: floating point value. Must be greater than 0.
5748 ///
5749 /// ## Return value
5750 /// Returns the logarithm of `x`.
5751 ///
5752 /// ## Thread safety
5753 /// It is safe to call this function from any thread.
5754 ///
5755 /// ## Availability
5756 /// This function is available since SDL 3.2.0.
5757 ///
5758 /// ## See also
5759 /// - [`SDL_log10`]
5760 /// - [`SDL_logf`]
5761 /// - [`SDL_powf`]
5762 pub safe fn SDL_log10f(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
5763}
5764
5765unsafe extern "C" {
5766 /// Split `x` into integer and fractional parts
5767 ///
5768 /// This function operates on double-precision floating point values, use
5769 /// [`SDL_modff`] for single-precision floats.
5770 ///
5771 /// ## Parameters
5772 /// - `x`: floating point value.
5773 /// - `y`: output pointer to store the integer part of `x`.
5774 ///
5775 /// ## Return value
5776 /// Returns the fractional part of `x`.
5777 ///
5778 /// ## Thread safety
5779 /// It is safe to call this function from any thread.
5780 ///
5781 /// ## Availability
5782 /// This function is available since SDL 3.2.0.
5783 ///
5784 /// ## See also
5785 /// - [`SDL_modff`]
5786 /// - [`SDL_trunc`]
5787 /// - [`SDL_fmod`]
5788 pub fn SDL_modf(
5789 x: ::core::ffi::c_double,
5790 y: *mut ::core::ffi::c_double,
5791 ) -> ::core::ffi::c_double;
5792}
5793
5794unsafe extern "C" {
5795 /// Split `x` into integer and fractional parts
5796 ///
5797 /// This function operates on single-precision floating point values, use
5798 /// [`SDL_modf`] for double-precision floats.
5799 ///
5800 /// ## Parameters
5801 /// - `x`: floating point value.
5802 /// - `y`: output pointer to store the integer part of `x`.
5803 ///
5804 /// ## Return value
5805 /// Returns the fractional part of `x`.
5806 ///
5807 /// ## Thread safety
5808 /// It is safe to call this function from any thread.
5809 ///
5810 /// ## Availability
5811 /// This function is available since SDL 3.2.0.
5812 ///
5813 /// ## See also
5814 /// - [`SDL_modf`]
5815 /// - [`SDL_truncf`]
5816 /// - [`SDL_fmodf`]
5817 pub fn SDL_modff(x: ::core::ffi::c_float, y: *mut ::core::ffi::c_float)
5818 -> ::core::ffi::c_float;
5819}
5820
5821unsafe extern "C" {
5822 /// Raise `x` to the power `y`
5823 ///
5824 /// Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
5825 ///
5826 /// Range: `-INF <= z <= INF`
5827 ///
5828 /// If `y` is the base of the natural logarithm (e), consider using [`SDL_exp`]
5829 /// instead.
5830 ///
5831 /// This function operates on double-precision floating point values, use
5832 /// [`SDL_powf`] for single-precision floats.
5833 ///
5834 /// This function may use a different approximation across different versions,
5835 /// platforms and configurations. i.e, it can return a different value given
5836 /// the same input on different machines or operating systems, or if SDL is
5837 /// updated.
5838 ///
5839 /// ## Parameters
5840 /// - `x`: the base.
5841 /// - `y`: the exponent.
5842 ///
5843 /// ## Return value
5844 /// Returns `x` raised to the power `y`.
5845 ///
5846 /// ## Thread safety
5847 /// It is safe to call this function from any thread.
5848 ///
5849 /// ## Availability
5850 /// This function is available since SDL 3.2.0.
5851 ///
5852 /// ## See also
5853 /// - [`SDL_powf`]
5854 /// - [`SDL_exp`]
5855 /// - [`SDL_log`]
5856 pub safe fn SDL_pow(
5857 x: ::core::ffi::c_double,
5858 y: ::core::ffi::c_double,
5859 ) -> ::core::ffi::c_double;
5860}
5861
5862unsafe extern "C" {
5863 /// Raise `x` to the power `y`
5864 ///
5865 /// Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
5866 ///
5867 /// Range: `-INF <= z <= INF`
5868 ///
5869 /// If `y` is the base of the natural logarithm (e), consider using [`SDL_exp`]
5870 /// instead.
5871 ///
5872 /// This function operates on single-precision floating point values, use
5873 /// [`SDL_pow`] for double-precision floats.
5874 ///
5875 /// This function may use a different approximation across different versions,
5876 /// platforms and configurations. i.e, it can return a different value given
5877 /// the same input on different machines or operating systems, or if SDL is
5878 /// updated.
5879 ///
5880 /// ## Parameters
5881 /// - `x`: the base.
5882 /// - `y`: the exponent.
5883 ///
5884 /// ## Return value
5885 /// Returns `x` raised to the power `y`.
5886 ///
5887 /// ## Thread safety
5888 /// It is safe to call this function from any thread.
5889 ///
5890 /// ## Availability
5891 /// This function is available since SDL 3.2.0.
5892 ///
5893 /// ## See also
5894 /// - [`SDL_pow`]
5895 /// - [`SDL_expf`]
5896 /// - [`SDL_logf`]
5897 pub safe fn SDL_powf(x: ::core::ffi::c_float, y: ::core::ffi::c_float) -> ::core::ffi::c_float;
5898}
5899
5900unsafe extern "C" {
5901 /// Round `x` to the nearest integer.
5902 ///
5903 /// Rounds `x` to the nearest integer. Values halfway between integers will be
5904 /// rounded away from zero.
5905 ///
5906 /// Domain: `-INF <= x <= INF`
5907 ///
5908 /// Range: `-INF <= y <= INF`, y integer
5909 ///
5910 /// This function operates on double-precision floating point values, use
5911 /// [`SDL_roundf`] for single-precision floats. To get the result as an integer
5912 /// type, use [`SDL_lround`].
5913 ///
5914 /// ## Parameters
5915 /// - `x`: floating point value.
5916 ///
5917 /// ## Return value
5918 /// Returns the nearest integer to `x`.
5919 ///
5920 /// ## Thread safety
5921 /// It is safe to call this function from any thread.
5922 ///
5923 /// ## Availability
5924 /// This function is available since SDL 3.2.0.
5925 ///
5926 /// ## See also
5927 /// - [`SDL_roundf`]
5928 /// - [`SDL_lround`]
5929 /// - [`SDL_floor`]
5930 /// - [`SDL_ceil`]
5931 /// - [`SDL_trunc`]
5932 pub safe fn SDL_round(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
5933}
5934
5935unsafe extern "C" {
5936 /// Round `x` to the nearest integer.
5937 ///
5938 /// Rounds `x` to the nearest integer. Values halfway between integers will be
5939 /// rounded away from zero.
5940 ///
5941 /// Domain: `-INF <= x <= INF`
5942 ///
5943 /// Range: `-INF <= y <= INF`, y integer
5944 ///
5945 /// This function operates on single-precision floating point values, use
5946 /// [`SDL_round`] for double-precision floats. To get the result as an integer
5947 /// type, use [`SDL_lroundf`].
5948 ///
5949 /// ## Parameters
5950 /// - `x`: floating point value.
5951 ///
5952 /// ## Return value
5953 /// Returns the nearest integer to `x`.
5954 ///
5955 /// ## Thread safety
5956 /// It is safe to call this function from any thread.
5957 ///
5958 /// ## Availability
5959 /// This function is available since SDL 3.2.0.
5960 ///
5961 /// ## See also
5962 /// - [`SDL_round`]
5963 /// - [`SDL_lroundf`]
5964 /// - [`SDL_floorf`]
5965 /// - [`SDL_ceilf`]
5966 /// - [`SDL_truncf`]
5967 pub safe fn SDL_roundf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
5968}
5969
5970unsafe extern "C" {
5971 /// Round `x` to the nearest integer representable as a long
5972 ///
5973 /// Rounds `x` to the nearest integer. Values halfway between integers will be
5974 /// rounded away from zero.
5975 ///
5976 /// Domain: `-INF <= x <= INF`
5977 ///
5978 /// Range: `MIN_LONG <= y <= MAX_LONG`
5979 ///
5980 /// This function operates on double-precision floating point values, use
5981 /// [`SDL_lroundf`] for single-precision floats. To get the result as a
5982 /// floating-point type, use [`SDL_round`].
5983 ///
5984 /// ## Parameters
5985 /// - `x`: floating point value.
5986 ///
5987 /// ## Return value
5988 /// Returns the nearest integer to `x`.
5989 ///
5990 /// ## Thread safety
5991 /// It is safe to call this function from any thread.
5992 ///
5993 /// ## Availability
5994 /// This function is available since SDL 3.2.0.
5995 ///
5996 /// ## See also
5997 /// - [`SDL_lroundf`]
5998 /// - [`SDL_round`]
5999 /// - [`SDL_floor`]
6000 /// - [`SDL_ceil`]
6001 /// - [`SDL_trunc`]
6002 pub safe fn SDL_lround(x: ::core::ffi::c_double) -> ::core::ffi::c_long;
6003}
6004
6005unsafe extern "C" {
6006 /// Round `x` to the nearest integer representable as a long
6007 ///
6008 /// Rounds `x` to the nearest integer. Values halfway between integers will be
6009 /// rounded away from zero.
6010 ///
6011 /// Domain: `-INF <= x <= INF`
6012 ///
6013 /// Range: `MIN_LONG <= y <= MAX_LONG`
6014 ///
6015 /// This function operates on single-precision floating point values, use
6016 /// [`SDL_lround`] for double-precision floats. To get the result as a
6017 /// floating-point type, use [`SDL_roundf`].
6018 ///
6019 /// ## Parameters
6020 /// - `x`: floating point value.
6021 ///
6022 /// ## Return value
6023 /// Returns the nearest integer to `x`.
6024 ///
6025 /// ## Thread safety
6026 /// It is safe to call this function from any thread.
6027 ///
6028 /// ## Availability
6029 /// This function is available since SDL 3.2.0.
6030 ///
6031 /// ## See also
6032 /// - [`SDL_lround`]
6033 /// - [`SDL_roundf`]
6034 /// - [`SDL_floorf`]
6035 /// - [`SDL_ceilf`]
6036 /// - [`SDL_truncf`]
6037 pub safe fn SDL_lroundf(x: ::core::ffi::c_float) -> ::core::ffi::c_long;
6038}
6039
6040unsafe extern "C" {
6041 /// Scale `x` by an integer power of two.
6042 ///
6043 /// Multiplies `x` by the `n`th power of the floating point radix (always 2).
6044 ///
6045 /// Domain: `-INF <= x <= INF`, `n` integer
6046 ///
6047 /// Range: `-INF <= y <= INF`
6048 ///
6049 /// This function operates on double-precision floating point values, use
6050 /// [`SDL_scalbnf`] for single-precision floats.
6051 ///
6052 /// ## Parameters
6053 /// - `x`: floating point value to be scaled.
6054 /// - `n`: integer exponent.
6055 ///
6056 /// ## Return value
6057 /// Returns `x * 2^n`.
6058 ///
6059 /// ## Thread safety
6060 /// It is safe to call this function from any thread.
6061 ///
6062 /// ## Availability
6063 /// This function is available since SDL 3.2.0.
6064 ///
6065 /// ## See also
6066 /// - [`SDL_scalbnf`]
6067 /// - [`SDL_pow`]
6068 pub safe fn SDL_scalbn(
6069 x: ::core::ffi::c_double,
6070 n: ::core::ffi::c_int,
6071 ) -> ::core::ffi::c_double;
6072}
6073
6074unsafe extern "C" {
6075 /// Scale `x` by an integer power of two.
6076 ///
6077 /// Multiplies `x` by the `n`th power of the floating point radix (always 2).
6078 ///
6079 /// Domain: `-INF <= x <= INF`, `n` integer
6080 ///
6081 /// Range: `-INF <= y <= INF`
6082 ///
6083 /// This function operates on single-precision floating point values, use
6084 /// [`SDL_scalbn`] for double-precision floats.
6085 ///
6086 /// ## Parameters
6087 /// - `x`: floating point value to be scaled.
6088 /// - `n`: integer exponent.
6089 ///
6090 /// ## Return value
6091 /// Returns `x * 2^n`.
6092 ///
6093 /// ## Thread safety
6094 /// It is safe to call this function from any thread.
6095 ///
6096 /// ## Availability
6097 /// This function is available since SDL 3.2.0.
6098 ///
6099 /// ## See also
6100 /// - [`SDL_scalbn`]
6101 /// - [`SDL_powf`]
6102 pub safe fn SDL_scalbnf(x: ::core::ffi::c_float, n: ::core::ffi::c_int)
6103 -> ::core::ffi::c_float;
6104}
6105
6106unsafe extern "C" {
6107 /// Compute the sine of `x`.
6108 ///
6109 /// Domain: `-INF <= x <= INF`
6110 ///
6111 /// Range: `-1 <= y <= 1`
6112 ///
6113 /// This function operates on double-precision floating point values, use
6114 /// [`SDL_sinf`] for single-precision floats.
6115 ///
6116 /// This function may use a different approximation across different versions,
6117 /// platforms and configurations. i.e, it can return a different value given
6118 /// the same input on different machines or operating systems, or if SDL is
6119 /// updated.
6120 ///
6121 /// ## Parameters
6122 /// - `x`: floating point value, in radians.
6123 ///
6124 /// ## Return value
6125 /// Returns sine of `x`.
6126 ///
6127 /// ## Thread safety
6128 /// It is safe to call this function from any thread.
6129 ///
6130 /// ## Availability
6131 /// This function is available since SDL 3.2.0.
6132 ///
6133 /// ## See also
6134 /// - [`SDL_sinf`]
6135 /// - [`SDL_asin`]
6136 /// - [`SDL_cos`]
6137 pub safe fn SDL_sin(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
6138}
6139
6140unsafe extern "C" {
6141 /// Compute the sine of `x`.
6142 ///
6143 /// Domain: `-INF <= x <= INF`
6144 ///
6145 /// Range: `-1 <= y <= 1`
6146 ///
6147 /// This function operates on single-precision floating point values, use
6148 /// [`SDL_sin`] for double-precision floats.
6149 ///
6150 /// This function may use a different approximation across different versions,
6151 /// platforms and configurations. i.e, it can return a different value given
6152 /// the same input on different machines or operating systems, or if SDL is
6153 /// updated.
6154 ///
6155 /// ## Parameters
6156 /// - `x`: floating point value, in radians.
6157 ///
6158 /// ## Return value
6159 /// Returns sine of `x`.
6160 ///
6161 /// ## Thread safety
6162 /// It is safe to call this function from any thread.
6163 ///
6164 /// ## Availability
6165 /// This function is available since SDL 3.2.0.
6166 ///
6167 /// ## See also
6168 /// - [`SDL_sin`]
6169 /// - [`SDL_asinf`]
6170 /// - [`SDL_cosf`]
6171 pub safe fn SDL_sinf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
6172}
6173
6174unsafe extern "C" {
6175 /// Compute the square root of `x`.
6176 ///
6177 /// Domain: `0 <= x <= INF`
6178 ///
6179 /// Range: `0 <= y <= INF`
6180 ///
6181 /// This function operates on double-precision floating point values, use
6182 /// [`SDL_sqrtf`] for single-precision floats.
6183 ///
6184 /// This function may use a different approximation across different versions,
6185 /// platforms and configurations. i.e, it can return a different value given
6186 /// the same input on different machines or operating systems, or if SDL is
6187 /// updated.
6188 ///
6189 /// ## Parameters
6190 /// - `x`: floating point value. Must be greater than or equal to 0.
6191 ///
6192 /// ## Return value
6193 /// Returns square root of `x`.
6194 ///
6195 /// ## Thread safety
6196 /// It is safe to call this function from any thread.
6197 ///
6198 /// ## Availability
6199 /// This function is available since SDL 3.2.0.
6200 ///
6201 /// ## See also
6202 /// - [`SDL_sqrtf`]
6203 pub safe fn SDL_sqrt(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
6204}
6205
6206unsafe extern "C" {
6207 /// Compute the square root of `x`.
6208 ///
6209 /// Domain: `0 <= x <= INF`
6210 ///
6211 /// Range: `0 <= y <= INF`
6212 ///
6213 /// This function operates on single-precision floating point values, use
6214 /// [`SDL_sqrt`] for double-precision floats.
6215 ///
6216 /// This function may use a different approximation across different versions,
6217 /// platforms and configurations. i.e, it can return a different value given
6218 /// the same input on different machines or operating systems, or if SDL is
6219 /// updated.
6220 ///
6221 /// ## Parameters
6222 /// - `x`: floating point value. Must be greater than or equal to 0.
6223 ///
6224 /// ## Return value
6225 /// Returns square root of `x`.
6226 ///
6227 /// ## Thread safety
6228 /// It is safe to call this function from any thread.
6229 ///
6230 /// ## Availability
6231 /// This function is available since SDL 3.2.0.
6232 ///
6233 /// ## See also
6234 /// - [`SDL_sqrt`]
6235 pub safe fn SDL_sqrtf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
6236}
6237
6238unsafe extern "C" {
6239 /// Compute the tangent of `x`.
6240 ///
6241 /// Domain: `-INF <= x <= INF`
6242 ///
6243 /// Range: `-INF <= y <= INF`
6244 ///
6245 /// This function operates on double-precision floating point values, use
6246 /// [`SDL_tanf`] for single-precision floats.
6247 ///
6248 /// This function may use a different approximation across different versions,
6249 /// platforms and configurations. i.e, it can return a different value given
6250 /// the same input on different machines or operating systems, or if SDL is
6251 /// updated.
6252 ///
6253 /// ## Parameters
6254 /// - `x`: floating point value, in radians.
6255 ///
6256 /// ## Return value
6257 /// Returns tangent of `x`.
6258 ///
6259 /// ## Thread safety
6260 /// It is safe to call this function from any thread.
6261 ///
6262 /// ## Availability
6263 /// This function is available since SDL 3.2.0.
6264 ///
6265 /// ## See also
6266 /// - [`SDL_tanf`]
6267 /// - [`SDL_sin`]
6268 /// - [`SDL_cos`]
6269 /// - [`SDL_atan`]
6270 /// - [`SDL_atan2`]
6271 pub safe fn SDL_tan(x: ::core::ffi::c_double) -> ::core::ffi::c_double;
6272}
6273
6274unsafe extern "C" {
6275 /// Compute the tangent of `x`.
6276 ///
6277 /// Domain: `-INF <= x <= INF`
6278 ///
6279 /// Range: `-INF <= y <= INF`
6280 ///
6281 /// This function operates on single-precision floating point values, use
6282 /// [`SDL_tan`] for double-precision floats.
6283 ///
6284 /// This function may use a different approximation across different versions,
6285 /// platforms and configurations. i.e, it can return a different value given
6286 /// the same input on different machines or operating systems, or if SDL is
6287 /// updated.
6288 ///
6289 /// ## Parameters
6290 /// - `x`: floating point value, in radians.
6291 ///
6292 /// ## Return value
6293 /// Returns tangent of `x`.
6294 ///
6295 /// ## Thread safety
6296 /// It is safe to call this function from any thread.
6297 ///
6298 /// ## Availability
6299 /// This function is available since SDL 3.2.0.
6300 ///
6301 /// ## See also
6302 /// - [`SDL_tan`]
6303 /// - [`SDL_sinf`]
6304 /// - [`SDL_cosf`]
6305 /// - [`SDL_atanf`]
6306 /// - [`SDL_atan2f`]
6307 pub safe fn SDL_tanf(x: ::core::ffi::c_float) -> ::core::ffi::c_float;
6308}
6309
6310/// An opaque handle representing string encoding conversion state.
6311///
6312/// ## Availability
6313/// This datatype is available since SDL 3.2.0.
6314///
6315/// ## See also
6316/// - [`SDL_iconv_open`]
6317pub type SDL_iconv_t = *mut SDL_iconv_data_t;
6318
6319unsafe extern "C" {
6320 /// This function allocates a context for the specified character set
6321 /// conversion.
6322 ///
6323 /// ## Parameters
6324 /// - `tocode`: The target character encoding, must not be NULL.
6325 /// - `fromcode`: The source character encoding, must not be NULL.
6326 ///
6327 /// ## Return value
6328 /// Returns a handle that must be freed with [`SDL_iconv_close`], or
6329 /// [`SDL_ICONV_ERROR`] on failure.
6330 ///
6331 /// ## Availability
6332 /// This function is available since SDL 3.2.0.
6333 ///
6334 /// ## See also
6335 /// - [`SDL_iconv`]
6336 /// - [`SDL_iconv_close`]
6337 /// - [`SDL_iconv_string`]
6338 pub fn SDL_iconv_open(
6339 tocode: *const ::core::ffi::c_char,
6340 fromcode: *const ::core::ffi::c_char,
6341 ) -> SDL_iconv_t;
6342}
6343
6344unsafe extern "C" {
6345 /// This function frees a context used for character set conversion.
6346 ///
6347 /// ## Parameters
6348 /// - `cd`: The character set conversion handle.
6349 ///
6350 /// ## Return value
6351 /// Returns 0 on success, or -1 on failure.
6352 ///
6353 /// ## Availability
6354 /// This function is available since SDL 3.2.0.
6355 ///
6356 /// ## See also
6357 /// - [`SDL_iconv`]
6358 /// - [`SDL_iconv_open`]
6359 /// - [`SDL_iconv_string`]
6360 pub fn SDL_iconv_close(cd: SDL_iconv_t) -> ::core::ffi::c_int;
6361}
6362
6363unsafe extern "C" {
6364 /// This function converts text between encodings, reading from and writing to
6365 /// a buffer.
6366 ///
6367 /// It returns the number of successful conversions on success. On error,
6368 /// [`SDL_ICONV_E2BIG`] is returned when the output buffer is too small, or
6369 /// [`SDL_ICONV_EILSEQ`] is returned when an invalid input sequence is encountered,
6370 /// or [`SDL_ICONV_EINVAL`] is returned when an incomplete input sequence is
6371 /// encountered.
6372 ///
6373 /// On exit:
6374 ///
6375 /// - inbuf will point to the beginning of the next multibyte sequence. On
6376 /// error, this is the location of the problematic input sequence. On
6377 /// success, this is the end of the input sequence.
6378 /// - inbytesleft will be set to the number of bytes left to convert, which
6379 /// will be 0 on success.
6380 /// - outbuf will point to the location where to store the next output byte.
6381 /// - outbytesleft will be set to the number of bytes left in the output
6382 /// buffer.
6383 ///
6384 /// ## Parameters
6385 /// - `cd`: The character set conversion context, created in
6386 /// [`SDL_iconv_open()`].
6387 /// - `inbuf`: Address of variable that points to the first character of the
6388 /// input sequence.
6389 /// - `inbytesleft`: The number of bytes in the input buffer.
6390 /// - `outbuf`: Address of variable that points to the output buffer.
6391 /// - `outbytesleft`: The number of bytes in the output buffer.
6392 ///
6393 /// ## Return value
6394 /// Returns the number of conversions on success, or a negative error code.
6395 ///
6396 /// ## Availability
6397 /// This function is available since SDL 3.2.0.
6398 ///
6399 /// ## See also
6400 /// - [`SDL_iconv_open`]
6401 /// - [`SDL_iconv_close`]
6402 /// - [`SDL_iconv_string`]
6403 pub fn SDL_iconv(
6404 cd: SDL_iconv_t,
6405 inbuf: *mut *const ::core::ffi::c_char,
6406 inbytesleft: *mut ::core::primitive::usize,
6407 outbuf: *mut *mut ::core::ffi::c_char,
6408 outbytesleft: *mut ::core::primitive::usize,
6409 ) -> ::core::primitive::usize;
6410}
6411
6412/// Generic error. Check [`SDL_GetError()`]?
6413pub const SDL_ICONV_ERROR: ::core::primitive::usize = (-1_i32 as ::core::primitive::usize);
6414
6415/// Output buffer was too small.
6416pub const SDL_ICONV_E2BIG: ::core::primitive::usize = (-2_i32 as ::core::primitive::usize);
6417
6418/// Invalid input sequence was encountered.
6419pub const SDL_ICONV_EILSEQ: ::core::primitive::usize = (-3_i32 as ::core::primitive::usize);
6420
6421/// Incomplete input sequence was encountered.
6422pub const SDL_ICONV_EINVAL: ::core::primitive::usize = (-4_i32 as ::core::primitive::usize);
6423
6424unsafe extern "C" {
6425 /// Helper function to convert a string's encoding in one call.
6426 ///
6427 /// This function converts a buffer or string between encodings in one pass.
6428 ///
6429 /// The string does not need to be NULL-terminated; this function operates on
6430 /// the number of bytes specified in `inbytesleft` whether there is a NULL
6431 /// character anywhere in the buffer.
6432 ///
6433 /// The returned string is owned by the caller, and should be passed to
6434 /// [`SDL_free`] when no longer needed.
6435 ///
6436 /// ## Parameters
6437 /// - `tocode`: the character encoding of the output string. Examples are
6438 /// "UTF-8", "UCS-4", etc.
6439 /// - `fromcode`: the character encoding of data in `inbuf`.
6440 /// - `inbuf`: the string to convert to a different encoding.
6441 /// - `inbytesleft`: the size of the input string _in bytes_.
6442 ///
6443 /// ## Return value
6444 /// Returns a new string, converted to the new encoding, or NULL on error.
6445 ///
6446 /// ## Availability
6447 /// This function is available since SDL 3.2.0.
6448 ///
6449 /// ## See also
6450 /// - [`SDL_iconv_open`]
6451 /// - [`SDL_iconv_close`]
6452 /// - [`SDL_iconv`]
6453 pub fn SDL_iconv_string(
6454 tocode: *const ::core::ffi::c_char,
6455 fromcode: *const ::core::ffi::c_char,
6456 inbuf: *const ::core::ffi::c_char,
6457 inbytesleft: ::core::primitive::usize,
6458 ) -> *mut ::core::ffi::c_char;
6459}
6460
6461/// Convert a UTF-8 string to the current locale's character encoding.
6462///
6463/// This is a helper macro that might be more clear than calling
6464/// [`SDL_iconv_string`] directly. However, it double-evaluates its parameter, so
6465/// do not use an expression with side-effects here.
6466///
6467/// ## Parameters
6468/// - `S`: the string to convert.
6469///
6470/// ## Return value
6471/// Returns a new string, converted to the new encoding, or NULL on error.
6472///
6473/// ## Availability
6474/// This macro is available since SDL 3.2.0.
6475#[inline(always)]
6476pub unsafe fn SDL_iconv_utf8_locale(S: *const ::core::ffi::c_char) -> *mut ::core::ffi::c_char {
6477 unsafe {
6478 SDL_iconv_string(
6479 c"".as_ptr(),
6480 c"UTF-8".as_ptr(),
6481 S,
6482 (unsafe { SDL_strlen(S) } + 1_usize),
6483 )
6484 }
6485}
6486
6487/// Convert a UTF-8 string to UCS-2.
6488///
6489/// This is a helper macro that might be more clear than calling
6490/// [`SDL_iconv_string`] directly. However, it double-evaluates its parameter, so
6491/// do not use an expression with side-effects here.
6492///
6493/// ## Parameters
6494/// - `S`: the string to convert.
6495///
6496/// ## Return value
6497/// Returns a new string, converted to the new encoding, or NULL on error.
6498///
6499/// ## Availability
6500/// This macro is available since SDL 3.2.0.
6501#[inline(always)]
6502pub unsafe fn SDL_iconv_utf8_ucs2(S: *const ::core::ffi::c_char) -> *mut Uint16 {
6503 (unsafe {
6504 SDL_iconv_string(
6505 c"UCS-2".as_ptr(),
6506 c"UTF-8".as_ptr(),
6507 S,
6508 (unsafe { SDL_strlen(S) } + 1_usize),
6509 )
6510 } as *mut Uint16)
6511}
6512
6513/// Convert a UTF-8 string to UCS-4.
6514///
6515/// This is a helper macro that might be more clear than calling
6516/// [`SDL_iconv_string`] directly. However, it double-evaluates its parameter, so
6517/// do not use an expression with side-effects here.
6518///
6519/// ## Parameters
6520/// - `S`: the string to convert.
6521///
6522/// ## Return value
6523/// Returns a new string, converted to the new encoding, or NULL on error.
6524///
6525/// ## Availability
6526/// This macro is available since SDL 3.2.0.
6527#[inline(always)]
6528pub unsafe fn SDL_iconv_utf8_ucs4(S: *const ::core::ffi::c_char) -> *mut Uint32 {
6529 (unsafe {
6530 SDL_iconv_string(
6531 c"UCS-4".as_ptr(),
6532 c"UTF-8".as_ptr(),
6533 S,
6534 (unsafe { SDL_strlen(S) } + 1_usize),
6535 )
6536 } as *mut Uint32)
6537}
6538
6539/// Convert a wchar_t string to UTF-8.
6540///
6541/// This is a helper macro that might be more clear than calling
6542/// [`SDL_iconv_string`] directly. However, it double-evaluates its parameter, so
6543/// do not use an expression with side-effects here.
6544///
6545/// ## Parameters
6546/// - `S`: the string to convert.
6547///
6548/// ## Return value
6549/// Returns a new string, converted to the new encoding, or NULL on error.
6550///
6551/// ## Availability
6552/// This macro is available since SDL 3.2.0.
6553#[inline(always)]
6554pub unsafe fn SDL_iconv_wchar_utf8(S: *const crate::ffi::c_wchar_t) -> *mut ::core::ffi::c_char {
6555 unsafe {
6556 SDL_iconv_string(
6557 c"UTF-8".as_ptr(),
6558 c"WCHAR_T".as_ptr(),
6559 (S as *const ::core::ffi::c_char),
6560 ((unsafe { SDL_wcslen(S) } + 1_usize)
6561 * ::core::mem::size_of::<crate::ffi::c_wchar_t>()),
6562 )
6563 }
6564}
6565
6566/// Multiply two integers, checking for overflow.
6567///
6568/// If `a * b` would overflow, return false.
6569///
6570/// Otherwise store `a * b` via ret and return true.
6571///
6572/// ## Parameters
6573/// - `a`: the multiplicand.
6574/// - `b`: the multiplier.
6575/// - `ret`: on non-overflow output, stores the multiplication result, may
6576/// not be NULL.
6577///
6578/// ## Return value
6579/// Returns false on overflow, true if result is multiplied without overflow.
6580///
6581/// ## Thread safety
6582/// It is safe to call this function from any thread.
6583///
6584/// ## Availability
6585/// This function is available since SDL 3.2.0.
6586#[inline(always)]
6587pub const unsafe fn SDL_size_mul_check_overflow(
6588 a: ::core::primitive::usize,
6589 b: ::core::primitive::usize,
6590 ret: *mut ::core::primitive::usize,
6591) -> ::core::primitive::bool {
6592 if ((a != 0_usize) && (b > (SDL_SIZE_MAX / a))) {
6593 return false;
6594 }
6595 unsafe {
6596 let (ptr, value) = (ret, (a * b));
6597 ptr.write(value);
6598 value
6599 };
6600 return true;
6601}
6602
6603apply_cfg!(#[cfg(not(doc))] => {
6604});
6605
6606/// Add two integers, checking for overflow.
6607///
6608/// If `a + b` would overflow, return false.
6609///
6610/// Otherwise store `a + b` via ret and return true.
6611///
6612/// ## Parameters
6613/// - `a`: the first addend.
6614/// - `b`: the second addend.
6615/// - `ret`: on non-overflow output, stores the addition result, may not be
6616/// NULL.
6617///
6618/// ## Return value
6619/// Returns false on overflow, true if result is added without overflow.
6620///
6621/// ## Thread safety
6622/// It is safe to call this function from any thread.
6623///
6624/// ## Availability
6625/// This function is available since SDL 3.2.0.
6626#[inline(always)]
6627pub const unsafe fn SDL_size_add_check_overflow(
6628 a: ::core::primitive::usize,
6629 b: ::core::primitive::usize,
6630 ret: *mut ::core::primitive::usize,
6631) -> ::core::primitive::bool {
6632 if (b > (SDL_SIZE_MAX - a)) {
6633 return false;
6634 }
6635 unsafe {
6636 let (ptr, value) = (ret, (a + b));
6637 ptr.write(value);
6638 value
6639 };
6640 return true;
6641}
6642
6643apply_cfg!(#[cfg(not(doc))] => {
6644});
6645
6646apply_cfg!(#[cfg(doc)] => {
6647 /// A generic function pointer.
6648 ///
6649 /// In theory, generic function pointers should use this, instead of `void *`,
6650 /// since some platforms could treat code addresses differently than data
6651 /// addresses. Although in current times no popular platforms make this
6652 /// distinction, it is more correct and portable to use the correct type for a
6653 /// generic pointer.
6654 ///
6655 /// If for some reason you need to force this typedef to be an actual `void *`,
6656 /// perhaps to work around a compiler or existing code, you can define
6657 /// `SDL_FUNCTION_POINTER_IS_VOID_POINTER` before including any SDL headers.
6658 ///
6659 /// ## Availability
6660 /// This datatype is available since SDL 3.2.0.
6661 pub type SDL_FunctionPointer = ::core::option::Option<unsafe extern "C" fn()>;
6662
6663});
6664
6665apply_cfg!(#[cfg(not(doc))] => {
6666 pub type SDL_FunctionPointer = ::core::option::Option<unsafe extern "C" fn()>;
6667
6668});
6669
6670/// A thread-safe set of environment variables
6671///
6672/// ## Availability
6673/// This struct is available since SDL 3.2.0.
6674///
6675/// ## See also
6676/// - [`SDL_GetEnvironment`]
6677/// - [`SDL_CreateEnvironment`]
6678/// - [`SDL_GetEnvironmentVariable`]
6679/// - [`SDL_GetEnvironmentVariables`]
6680/// - [`SDL_SetEnvironmentVariable`]
6681/// - [`SDL_UnsetEnvironmentVariable`]
6682/// - [`SDL_DestroyEnvironment`]
6683#[repr(C)]
6684pub struct SDL_Environment {
6685 _opaque: [::core::primitive::u8; 0],
6686}
6687
6688#[repr(C)]
6689pub struct SDL_iconv_data_t {
6690 _opaque: [::core::primitive::u8; 0],
6691}
6692
6693#[cfg(doc)]
6694use crate::everything::*;