| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Stdinc
Description
SDL's C-library replacements: memory, strings, math, and conversions; this module aliases the allocator and SDL's own API.
FFI conventions
Unsuffixed aliases are unsafe foreign imports; aliases suffixed Safe are safe. Functions whose callbacks fire during the call export only the Safe alias (the genuine unsafe import stays reachable under SDL3.Sys.Bindgen.Stdinc.Unsafe); functions curated unsafe-only export only the unsuffixed one. Each alias's documentation records its flavor and rationale.
This module aliases only the functions of SDL_stdinc.h that the registry allowlists. The header's other functions are raw-only: SDL3.Sys.Bindgen.Stdinc.Unsafe and SDL3.Sys.Bindgen.Stdinc.Safe export them.
The C shims are functions this package defines in C over what the FFI cannot call directly (variadic functions, function-like macros), each named after what it wraps; the same flavor rules apply. Their raw imports live under SDL3.Sys.Bindgen.StdincShims.
Full conventions: SDL3.Sys.
Allowlist
The aliases are SDL's own API in this header (environments, the memory-function hooks and allocation count, UTF-8 stepping) and the allocator family, since memory SDL frees, or hands you to free, must come from SDL's allocator: malloc, free, strdup, and their kin. The rest of the header serves C programs without a portable C library: strings, character classes, math, sorting, random numbers, checksums, iconv, memcpy. Haskell has its own, so they stay raw-only.
Synopsis
- module SDL3.Sys.Bindgen.Stdinc
- pattern SDL_MAX_TIME :: SDL_Time
- pattern SDL_MIN_TIME :: SDL_Time
- pattern SDL_MAX_SINT16 :: Sint16
- pattern SDL_MIN_SINT16 :: Sint16
- pattern SDL_MAX_SINT32 :: Sint32
- pattern SDL_MIN_SINT32 :: Sint32
- pattern SDL_MAX_SINT64 :: Sint64
- pattern SDL_MIN_SINT64 :: Sint64
- pattern SDL_MAX_SINT8 :: Sint8
- pattern SDL_MIN_SINT8 :: Sint8
- pattern SDL_MAX_UINT16 :: Uint16
- pattern SDL_MIN_UINT16 :: Uint16
- pattern SDL_MAX_UINT32 :: Uint32
- pattern SDL_MIN_UINT32 :: Uint32
- pattern SDL_MAX_UINT64 :: Uint64
- pattern SDL_MIN_UINT64 :: Uint64
- pattern SDL_MAX_UINT8 :: Uint8
- pattern SDL_MIN_UINT8 :: Uint8
- pattern SDL_SIZE_MAX :: Word64
- pattern SDL_ICONV_ERROR :: Word64
- pattern SDL_ICONV_E2BIG :: Word64
- pattern SDL_ICONV_EILSEQ :: Word64
- pattern SDL_ICONV_EINVAL :: Word64
- malloc :: Word64 -> IO (Ptr Void)
- mallocSafe :: Word64 -> IO (Ptr Void)
- calloc :: Word64 -> Word64 -> IO (Ptr Void)
- callocSafe :: Word64 -> Word64 -> IO (Ptr Void)
- realloc :: Ptr Void -> Word64 -> IO (Ptr Void)
- reallocSafe :: Ptr Void -> Word64 -> IO (Ptr Void)
- free :: Ptr Void -> IO ()
- freeSafe :: Ptr Void -> IO ()
- getOriginalMemoryFunctions :: Ptr SDL_malloc_func -> Ptr SDL_calloc_func -> Ptr SDL_realloc_func -> Ptr SDL_free_func -> IO ()
- getOriginalMemoryFunctionsSafe :: Ptr SDL_malloc_func -> Ptr SDL_calloc_func -> Ptr SDL_realloc_func -> Ptr SDL_free_func -> IO ()
- getMemoryFunctions :: Ptr SDL_malloc_func -> Ptr SDL_calloc_func -> Ptr SDL_realloc_func -> Ptr SDL_free_func -> IO ()
- getMemoryFunctionsSafe :: Ptr SDL_malloc_func -> Ptr SDL_calloc_func -> Ptr SDL_realloc_func -> Ptr SDL_free_func -> IO ()
- setMemoryFunctions :: SDL_malloc_func -> SDL_calloc_func -> SDL_realloc_func -> SDL_free_func -> IO Bool
- setMemoryFunctionsSafe :: SDL_malloc_func -> SDL_calloc_func -> SDL_realloc_func -> SDL_free_func -> IO Bool
- alignedAlloc :: Word64 -> Word64 -> IO (Ptr Void)
- alignedAllocSafe :: Word64 -> Word64 -> IO (Ptr Void)
- alignedFree :: Ptr Void -> IO ()
- alignedFreeSafe :: Ptr Void -> IO ()
- getNumAllocations :: IO Int32
- getNumAllocationsSafe :: IO Int32
- getEnvironment :: IO (Ptr SDL_Environment)
- getEnvironmentSafe :: IO (Ptr SDL_Environment)
- createEnvironment :: Bool -> IO (Ptr SDL_Environment)
- createEnvironmentSafe :: Bool -> IO (Ptr SDL_Environment)
- getEnvironmentVariable :: Ptr SDL_Environment -> PtrConst CChar -> IO (PtrConst CChar)
- getEnvironmentVariableSafe :: Ptr SDL_Environment -> PtrConst CChar -> IO (PtrConst CChar)
- getEnvironmentVariables :: Ptr SDL_Environment -> IO (Ptr (Ptr CChar))
- getEnvironmentVariablesSafe :: Ptr SDL_Environment -> IO (Ptr (Ptr CChar))
- setEnvironmentVariable :: Ptr SDL_Environment -> PtrConst CChar -> PtrConst CChar -> Bool -> IO Bool
- setEnvironmentVariableSafe :: Ptr SDL_Environment -> PtrConst CChar -> PtrConst CChar -> Bool -> IO Bool
- unsetEnvironmentVariable :: Ptr SDL_Environment -> PtrConst CChar -> IO Bool
- unsetEnvironmentVariableSafe :: Ptr SDL_Environment -> PtrConst CChar -> IO Bool
- destroyEnvironment :: Ptr SDL_Environment -> IO ()
- destroyEnvironmentSafe :: Ptr SDL_Environment -> IO ()
- strdup :: PtrConst CChar -> IO (Ptr CChar)
- strdupSafe :: PtrConst CChar -> IO (Ptr CChar)
- strndup :: PtrConst CChar -> Word64 -> IO (Ptr CChar)
- strndupSafe :: PtrConst CChar -> Word64 -> IO (Ptr CChar)
- stepUTF8 :: Ptr (PtrConst CChar) -> Ptr CSize -> IO Word32
- stepBackUTF8 :: PtrConst CChar -> Ptr (PtrConst CChar) -> IO Word32
- ucs4ToUTF8 :: Word32 -> Ptr CChar -> IO (Ptr CChar)
- fourCC :: Word8 -> Word8 -> Word8 -> Word8 -> IO Word32
Documentation
module SDL3.Sys.Bindgen.Stdinc
Typed constants
pattern SDL_MAX_TIME :: SDL_Time Source #
Typed constant for macro SDL_MAX_TIME.
pattern SDL_MIN_TIME :: SDL_Time Source #
Typed constant for macro SDL_MIN_TIME.
pattern SDL_MAX_SINT16 :: Sint16 Source #
Typed constant for macro SDL_MAX_SINT16.
pattern SDL_MIN_SINT16 :: Sint16 Source #
Typed constant for macro SDL_MIN_SINT16.
pattern SDL_MAX_SINT32 :: Sint32 Source #
Typed constant for macro SDL_MAX_SINT32.
pattern SDL_MIN_SINT32 :: Sint32 Source #
Typed constant for macro SDL_MIN_SINT32.
pattern SDL_MAX_SINT64 :: Sint64 Source #
Typed constant for macro SDL_MAX_SINT64.
pattern SDL_MIN_SINT64 :: Sint64 Source #
Typed constant for macro SDL_MIN_SINT64.
pattern SDL_MAX_SINT8 :: Sint8 Source #
Typed constant for macro SDL_MAX_SINT8.
pattern SDL_MIN_SINT8 :: Sint8 Source #
Typed constant for macro SDL_MIN_SINT8.
pattern SDL_MAX_UINT16 :: Uint16 Source #
Typed constant for macro SDL_MAX_UINT16.
pattern SDL_MIN_UINT16 :: Uint16 Source #
Typed constant for macro SDL_MIN_UINT16.
pattern SDL_MAX_UINT32 :: Uint32 Source #
Typed constant for macro SDL_MAX_UINT32.
pattern SDL_MIN_UINT32 :: Uint32 Source #
Typed constant for macro SDL_MIN_UINT32.
pattern SDL_MAX_UINT64 :: Uint64 Source #
Typed constant for macro SDL_MAX_UINT64.
pattern SDL_MIN_UINT64 :: Uint64 Source #
Typed constant for macro SDL_MIN_UINT64.
pattern SDL_MAX_UINT8 :: Uint8 Source #
Typed constant for macro SDL_MAX_UINT8.
pattern SDL_MIN_UINT8 :: Uint8 Source #
Typed constant for macro SDL_MIN_UINT8.
pattern SDL_SIZE_MAX :: Word64 Source #
Typed constant for macro SDL_SIZE_MAX (C type size_t).
pattern SDL_ICONV_ERROR :: Word64 Source #
Typed constant for macro SDL_ICONV_ERROR (C type size_t).
pattern SDL_ICONV_E2BIG :: Word64 Source #
Typed constant for macro SDL_ICONV_E2BIG (C type size_t).
pattern SDL_ICONV_EILSEQ :: Word64 Source #
Typed constant for macro SDL_ICONV_EILSEQ (C type size_t).
pattern SDL_ICONV_EINVAL :: Word64 Source #
Typed constant for macro SDL_ICONV_EINVAL (C type size_t).
Function aliases
Allocate uninitialized memory.
The allocated memory returned by this function must be freed with .free
If size is 0, it will be set to 1.
If the allocation is successful, the returned pointer is guaranteed to be aligned to either the fundamental alignment (alignof(max_align_t) in C11 and later) or 2 * sizeof(void *), whichever is smaller. Use if you need to allocate memory aligned to an alignment greater than this guarantee.alignedAlloc
- Returns
- a pointer to the allocated memory, or NULL if allocation failed.
- Thread safety
- It is safe to call this function from any thread.
- See also
free,calloc,realloc,alignedAlloc
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_malloc. The safe flavor ismallocSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_malloc, defined atSDL3/SDL_stdinc.h 1342:47
Since: 3.2.0
Allocate uninitialized memory.
The allocated memory returned by this function must be freed with .free
If size is 0, it will be set to 1.
If the allocation is successful, the returned pointer is guaranteed to be aligned to either the fundamental alignment (alignof(max_align_t) in C11 and later) or 2 * sizeof(void *), whichever is smaller. Use if you need to allocate memory aligned to an alignment greater than this guarantee.alignedAlloc
- Returns
- a pointer to the allocated memory, or NULL if allocation failed.
- Thread safety
- It is safe to call this function from any thread.
- See also
free,calloc,realloc,alignedAlloc
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_malloc. The unsafe flavor ismalloc. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_malloc, defined atSDL3/SDL_stdinc.h 1342:47
Since: 3.2.0
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_calloc. The safe flavor iscallocSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_calloc, defined atSDL3/SDL_stdinc.h 1367:69
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_calloc. The unsafe flavor iscalloc. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_calloc, defined atSDL3/SDL_stdinc.h 1367:69
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_realloc. The safe flavor isreallocSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_realloc, defined atSDL3/SDL_stdinc.h 1407:54
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_realloc. The unsafe flavor isrealloc. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_realloc, defined atSDL3/SDL_stdinc.h 1407:54
Free allocated memory.
The pointer is no longer valid after this call and cannot be dereferenced anymore.
If mem is NULL, this function does nothing.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_free. The safe flavor isfreeSafe. - C declaration
SDL_free, defined atSDL3/SDL_stdinc.h 1427:34
Since: 3.2.0
Free allocated memory.
The pointer is no longer valid after this call and cannot be dereferenced anymore.
If mem is NULL, this function does nothing.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_free. The unsafe flavor isfree. - C declaration
SDL_free, defined atSDL3/SDL_stdinc.h 1427:34
Since: 3.2.0
getOriginalMemoryFunctions Source #
Arguments
| :: Ptr SDL_malloc_func |
|
| -> Ptr SDL_calloc_func |
|
| -> Ptr SDL_realloc_func |
|
| -> Ptr SDL_free_func |
|
| -> IO () |
Get the original set of SDL memory functions.
This is what malloc and friends will use by default, if there has been no call to setMemoryFunctions. This is not necessarily using the C runtime's malloc functions behind the scenes! Different platforms and build configurations might do any number of unexpected things.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetOriginalMemoryFunctions. The safe flavor isgetOriginalMemoryFunctionsSafe. - C declaration
SDL_GetOriginalMemoryFunctions, defined atSDL3/SDL_stdinc.h 1525:34
Since: 3.2.0
getOriginalMemoryFunctionsSafe Source #
Arguments
| :: Ptr SDL_malloc_func |
|
| -> Ptr SDL_calloc_func |
|
| -> Ptr SDL_realloc_func |
|
| -> Ptr SDL_free_func |
|
| -> IO () |
Get the original set of SDL memory functions.
This is what malloc and friends will use by default, if there has been no call to setMemoryFunctions. This is not necessarily using the C runtime's malloc functions behind the scenes! Different platforms and build configurations might do any number of unexpected things.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetOriginalMemoryFunctions. The unsafe flavor isgetOriginalMemoryFunctions. - C declaration
SDL_GetOriginalMemoryFunctions, defined atSDL3/SDL_stdinc.h 1525:34
Since: 3.2.0
Arguments
| :: Ptr SDL_malloc_func |
|
| -> Ptr SDL_calloc_func |
|
| -> Ptr SDL_realloc_func |
|
| -> Ptr SDL_free_func |
|
| -> IO () |
Get the current set of SDL memory functions.
- Thread safety
- This does not hold a lock, so do not call this in the unlikely event of a background thread calling
setMemoryFunctionssimultaneously. - See also
setMemoryFunctions,getOriginalMemoryFunctions
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetMemoryFunctions. The safe flavor isgetMemoryFunctionsSafe. - C declaration
SDL_GetMemoryFunctions, defined atSDL3/SDL_stdinc.h 1547:34
Since: 3.2.0
getMemoryFunctionsSafe Source #
Arguments
| :: Ptr SDL_malloc_func |
|
| -> Ptr SDL_calloc_func |
|
| -> Ptr SDL_realloc_func |
|
| -> Ptr SDL_free_func |
|
| -> IO () |
Get the current set of SDL memory functions.
- Thread safety
- This does not hold a lock, so do not call this in the unlikely event of a background thread calling
setMemoryFunctionssimultaneously. - See also
setMemoryFunctions,getOriginalMemoryFunctions
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetMemoryFunctions. The unsafe flavor isgetMemoryFunctions. - C declaration
SDL_GetMemoryFunctions, defined atSDL3/SDL_stdinc.h 1547:34
Since: 3.2.0
Arguments
| :: SDL_malloc_func |
|
| -> SDL_calloc_func |
|
| -> SDL_realloc_func |
|
| -> SDL_free_func |
|
| -> IO Bool |
Replace SDL's memory allocation functions with a custom set.
It is not safe to call this function once any allocations have been made, as future calls to free will use the new allocator, even if they came from an malloc made with the old one!
If used, usually this needs to be the first call made into the SDL library, if not the very first thing done at program startup time.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread, but one should not replace the memory functions once any allocations are made!
- See also
getMemoryFunctions,getOriginalMemoryFunctions
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_SetMemoryFunctions. The safe flavor issetMemoryFunctionsSafe: registration; replacement allocators run inside every later SDL call. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_SetMemoryFunctions, defined atSDL3/SDL_stdinc.h 1578:34
Since: 3.2.0
setMemoryFunctionsSafe Source #
Arguments
| :: SDL_malloc_func |
|
| -> SDL_calloc_func |
|
| -> SDL_realloc_func |
|
| -> SDL_free_func |
|
| -> IO Bool |
Replace SDL's memory allocation functions with a custom set.
It is not safe to call this function once any allocations have been made, as future calls to free will use the new allocator, even if they came from an malloc made with the old one!
If used, usually this needs to be the first call made into the SDL library, if not the very first thing done at program startup time.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread, but one should not replace the memory functions once any allocations are made!
- See also
getMemoryFunctions,getOriginalMemoryFunctions
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_SetMemoryFunctions. The unsafe flavor issetMemoryFunctions: registration; replacement allocators run inside every later SDL call. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_SetMemoryFunctions, defined atSDL3/SDL_stdinc.h 1578:34
Since: 3.2.0
Arguments
| :: Word64 |
|
| -> Word64 |
|
| -> IO (Ptr Void) |
Allocate memory aligned to a specific alignment.
The memory returned by this function must be freed with , not alignedFree.free
If alignment is less than the size of void *, it will be increased to match that.
The returned memory address will be a multiple of the alignment value, and the size of the memory allocated will be a multiple of the alignment value.
- Returns
- a pointer to the aligned memory, or NULL if allocation failed.
- Thread safety
- It is safe to call this function from any thread.
- See also
alignedFree
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_aligned_alloc. The safe flavor isalignedAllocSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_aligned_alloc, defined atSDL3/SDL_stdinc.h 1605:47
Since: 3.2.0
Arguments
| :: Word64 |
|
| -> Word64 |
|
| -> IO (Ptr Void) |
Allocate memory aligned to a specific alignment.
The memory returned by this function must be freed with , not alignedFree.free
If alignment is less than the size of void *, it will be increased to match that.
The returned memory address will be a multiple of the alignment value, and the size of the memory allocated will be a multiple of the alignment value.
- Returns
- a pointer to the aligned memory, or NULL if allocation failed.
- Thread safety
- It is safe to call this function from any thread.
- See also
alignedFree
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_aligned_alloc. The unsafe flavor isalignedAlloc. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_aligned_alloc, defined atSDL3/SDL_stdinc.h 1605:47
Since: 3.2.0
Arguments
| :: Ptr Void |
|
| -> IO () |
Free memory allocated by .alignedAlloc
The pointer is no longer valid after this call and cannot be dereferenced anymore.
If mem is NULL, this function does nothing.
- Thread safety
- It is safe to call this function from any thread.
- See also
alignedAlloc
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_aligned_free. The safe flavor isalignedFreeSafe. - C declaration
SDL_aligned_free, defined atSDL3/SDL_stdinc.h 1623:34
Since: 3.2.0
Arguments
| :: Ptr Void |
|
| -> IO () |
Free memory allocated by .alignedAlloc
The pointer is no longer valid after this call and cannot be dereferenced anymore.
If mem is NULL, this function does nothing.
- Thread safety
- It is safe to call this function from any thread.
- See also
alignedAlloc
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_aligned_free. The unsafe flavor isalignedFree. - C declaration
SDL_aligned_free, defined atSDL3/SDL_stdinc.h 1623:34
Since: 3.2.0
getNumAllocations :: IO Int32 Source #
Get the number of outstanding (unfreed) allocations.
- Returns
- the number of allocations or -1 if allocation counting is disabled.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetNumAllocations. The safe flavor isgetNumAllocationsSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetNumAllocations, defined atSDL3/SDL_stdinc.h 1635:33
Since: 3.2.0
getNumAllocationsSafe :: IO Int32 Source #
Get the number of outstanding (unfreed) allocations.
- Returns
- the number of allocations or -1 if allocation counting is disabled.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetNumAllocations. The unsafe flavor isgetNumAllocations. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetNumAllocations, defined atSDL3/SDL_stdinc.h 1635:33
Since: 3.2.0
getEnvironment :: IO (Ptr SDL_Environment) Source #
Get the process environment.
This is initialized at application start and is not affected by setenv() and unsetenv() calls after that point. Use and setEnvironmentVariable if you want to modify this environment, or unsetEnvironmentVariable or sDL_setenv_unsafe if you want changes to persist in the C runtime environment after sDL_unsetenv_unsafequit.
- Returns
- a pointer to the environment for the process or NULL on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
getEnvironmentVariable,getEnvironmentVariables,setEnvironmentVariable,unsetEnvironmentVariable
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetEnvironment. The safe flavor isgetEnvironmentSafe. - C declaration
SDL_GetEnvironment, defined atSDL3/SDL_stdinc.h 1673:47
Since: 3.2.0
getEnvironmentSafe :: IO (Ptr SDL_Environment) Source #
Get the process environment.
This is initialized at application start and is not affected by setenv() and unsetenv() calls after that point. Use and setEnvironmentVariable if you want to modify this environment, or unsetEnvironmentVariable or sDL_setenv_unsafe if you want changes to persist in the C runtime environment after sDL_unsetenv_unsafequit.
- Returns
- a pointer to the environment for the process or NULL on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
getEnvironmentVariable,getEnvironmentVariables,setEnvironmentVariable,unsetEnvironmentVariable
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetEnvironment. The unsafe flavor isgetEnvironment. - C declaration
SDL_GetEnvironment, defined atSDL3/SDL_stdinc.h 1673:47
Since: 3.2.0
Arguments
| :: Bool |
|
| -> IO (Ptr SDL_Environment) |
Create a set of environment variables
- Returns
- a pointer to the new environment or NULL on failure; call
getErrorfor more information. - Thread safety
- If
populatedis false, it is safe to call this function from any thread, otherwise it is safe if no other threads are calling setenv() or unsetenv() - See also
getEnvironmentVariable,getEnvironmentVariables,setEnvironmentVariable,unsetEnvironmentVariable,destroyEnvironment
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_CreateEnvironment. The safe flavor iscreateEnvironmentSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_CreateEnvironment, defined atSDL3/SDL_stdinc.h 1695:47
Since: 3.2.0
createEnvironmentSafe Source #
Arguments
| :: Bool |
|
| -> IO (Ptr SDL_Environment) |
Create a set of environment variables
- Returns
- a pointer to the new environment or NULL on failure; call
getErrorfor more information. - Thread safety
- If
populatedis false, it is safe to call this function from any thread, otherwise it is safe if no other threads are calling setenv() or unsetenv() - See also
getEnvironmentVariable,getEnvironmentVariables,setEnvironmentVariable,unsetEnvironmentVariable,destroyEnvironment
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_CreateEnvironment. The unsafe flavor iscreateEnvironment. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_CreateEnvironment, defined atSDL3/SDL_stdinc.h 1695:47
Since: 3.2.0
getEnvironmentVariable Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> PtrConst CChar |
|
| -> IO (PtrConst CChar) |
Get the value of a variable in the environment.
- Returns
- a pointer to the value of the variable or NULL if it can't be found.
- Thread safety
- It is safe to call this function from any thread.
- See also
getEnvironment,createEnvironment,getEnvironmentVariables,setEnvironmentVariable,unsetEnvironmentVariable
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetEnvironmentVariable. The safe flavor isgetEnvironmentVariableSafe. - C declaration
SDL_GetEnvironmentVariable, defined atSDL3/SDL_stdinc.h 1715:42
Since: 3.2.0
getEnvironmentVariableSafe Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> PtrConst CChar |
|
| -> IO (PtrConst CChar) |
Get the value of a variable in the environment.
- Returns
- a pointer to the value of the variable or NULL if it can't be found.
- Thread safety
- It is safe to call this function from any thread.
- See also
getEnvironment,createEnvironment,getEnvironmentVariables,setEnvironmentVariable,unsetEnvironmentVariable
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetEnvironmentVariable. The unsafe flavor isgetEnvironmentVariable. - C declaration
SDL_GetEnvironmentVariable, defined atSDL3/SDL_stdinc.h 1715:42
Since: 3.2.0
getEnvironmentVariables Source #
Get all variables in the environment.
- Returns
- a NULL terminated array of pointers to environment variables in the form "variable=value" or NULL on failure; call
getErrorfor more information. This is a single allocation that should be freed withwhen it is no longer needed.free - Thread safety
- It is safe to call this function from any thread.
- See also
getEnvironment,createEnvironment,getEnvironmentVariables,setEnvironmentVariable,unsetEnvironmentVariable
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetEnvironmentVariables. The safe flavor isgetEnvironmentVariablesSafe. - C declaration
SDL_GetEnvironmentVariables, defined atSDL3/SDL_stdinc.h 1736:37
Since: 3.2.0
getEnvironmentVariablesSafe Source #
Get all variables in the environment.
- Returns
- a NULL terminated array of pointers to environment variables in the form "variable=value" or NULL on failure; call
getErrorfor more information. This is a single allocation that should be freed withwhen it is no longer needed.free - Thread safety
- It is safe to call this function from any thread.
- See also
getEnvironment,createEnvironment,getEnvironmentVariables,setEnvironmentVariable,unsetEnvironmentVariable
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetEnvironmentVariables. The unsafe flavor isgetEnvironmentVariables. - C declaration
SDL_GetEnvironmentVariables, defined atSDL3/SDL_stdinc.h 1736:37
Since: 3.2.0
setEnvironmentVariable Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> Bool |
|
| -> IO Bool |
Set the value of a variable in the environment.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
getEnvironment,createEnvironment,getEnvironmentVariable,getEnvironmentVariables,unsetEnvironmentVariable
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_SetEnvironmentVariable. The safe flavor issetEnvironmentVariableSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_SetEnvironmentVariable, defined atSDL3/SDL_stdinc.h 1760:34
Since: 3.2.0
setEnvironmentVariableSafe Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> Bool |
|
| -> IO Bool |
Set the value of a variable in the environment.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
getEnvironment,createEnvironment,getEnvironmentVariable,getEnvironmentVariables,unsetEnvironmentVariable
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_SetEnvironmentVariable. The unsafe flavor issetEnvironmentVariable. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_SetEnvironmentVariable, defined atSDL3/SDL_stdinc.h 1760:34
Since: 3.2.0
unsetEnvironmentVariable Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> PtrConst CChar |
|
| -> IO Bool |
Clear a variable from the environment.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
getEnvironment,createEnvironment,getEnvironmentVariable,getEnvironmentVariables,setEnvironmentVariable,unsetEnvironmentVariable
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_UnsetEnvironmentVariable. The safe flavor isunsetEnvironmentVariableSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_UnsetEnvironmentVariable, defined atSDL3/SDL_stdinc.h 1781:34
Since: 3.2.0
unsetEnvironmentVariableSafe Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> PtrConst CChar |
|
| -> IO Bool |
Clear a variable from the environment.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
getEnvironment,createEnvironment,getEnvironmentVariable,getEnvironmentVariables,setEnvironmentVariable,unsetEnvironmentVariable
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_UnsetEnvironmentVariable. The unsafe flavor isunsetEnvironmentVariable. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_UnsetEnvironmentVariable, defined atSDL3/SDL_stdinc.h 1781:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Environment |
|
| -> IO () |
Destroy a set of environment variables.
- Thread safety
- It is safe to call this function from any thread, as long as the environment is no longer in use.
- See also
createEnvironment
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_DestroyEnvironment. The safe flavor isdestroyEnvironmentSafe. - C declaration
SDL_DestroyEnvironment, defined atSDL3/SDL_stdinc.h 1795:34
Since: 3.2.0
destroyEnvironmentSafe Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> IO () |
Destroy a set of environment variables.
- Thread safety
- It is safe to call this function from any thread, as long as the environment is no longer in use.
- See also
createEnvironment
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_DestroyEnvironment. The unsafe flavor isdestroyEnvironment. - C declaration
SDL_DestroyEnvironment, defined atSDL3/SDL_stdinc.h 1795:34
Since: 3.2.0
Allocate a copy of a string.
This allocates enough space for a null-terminated copy of str, using malloc, and then makes a copy of the string into this space.
The returned string is owned by the caller, and should be passed to free when no longer needed.
- Returns
- a pointer to the newly-allocated string.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_strdup. The safe flavor isstrdupSafe. - C declaration
SDL_strdup, defined atSDL3/SDL_stdinc.h 3164:47
Since: 3.2.0
Allocate a copy of a string.
This allocates enough space for a null-terminated copy of str, using malloc, and then makes a copy of the string into this space.
The returned string is owned by the caller, and should be passed to free when no longer needed.
- Returns
- a pointer to the newly-allocated string.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_strdup. The unsafe flavor isstrdup. - C declaration
SDL_strdup, defined atSDL3/SDL_stdinc.h 3164:47
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> Word64 |
|
| -> IO (Ptr CChar) |
Allocate a copy of a string, up to n characters.
This allocates enough space for a null-terminated copy of str, up to maxlen bytes, using malloc, and then makes a copy of the string into this space.
If the string is longer than maxlen bytes, the returned string will be maxlen bytes long, plus a null-terminator character that isn't included in the count.
The returned string is owned by the caller, and should be passed to free when no longer needed.
- Returns
- a pointer to the newly-allocated string.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_strndup. The safe flavor isstrndupSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_strndup, defined atSDL3/SDL_stdinc.h 3189:47
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> Word64 |
|
| -> IO (Ptr CChar) |
Allocate a copy of a string, up to n characters.
This allocates enough space for a null-terminated copy of str, up to maxlen bytes, using malloc, and then makes a copy of the string into this space.
If the string is longer than maxlen bytes, the returned string will be maxlen bytes long, plus a null-terminator character that isn't included in the count.
The returned string is owned by the caller, and should be passed to free when no longer needed.
- Returns
- a pointer to the newly-allocated string.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_strndup. The unsafe flavor isstrndup. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_strndup, defined atSDL3/SDL_stdinc.h 3189:47
Since: 3.2.0
Arguments
| :: Ptr (PtrConst CChar) |
|
| -> Ptr CSize |
|
| -> IO Word32 |
Decode a UTF-8 string, one Unicode codepoint at a time.
This will return the first Unicode codepoint in the UTF-8 encoded string in *pstr, and then advance *pstr past any consumed bytes before returning.
It will not access more than *pslen bytes from the string. *pslen will be adjusted, as well, subtracting the number of bytes consumed.
pslen is allowed to be NULL, in which case the string must be NULL-terminated, as the function will blindly read until it sees the NULL char.
if *pslen is zero, it assumes the end of string is reached and returns a zero codepoint regardless of the contents of the string buffer.
If the resulting codepoint is zero (a NULL terminator), or *pslen is zero, it will not advance *pstr or *pslen at all.
Generally this function is called in a loop until it returns zero, adjusting its parameters each iteration.
If an invalid UTF-8 sequence is encountered, this function returns SDL_INVALID_UNICODE_CODEPOINT and advances the string/length by one byte (which is to say, a multibyte sequence might produce several SDL_INVALID_UNICODE_CODEPOINT returns before it syncs to the next valid UTF-8 sequence).
Several things can generate invalid UTF-8 sequences, including overlong encodings, the use of UTF-16 surrogate values, and truncated data. Please refer to RFC3629 for details.
- Returns
- the first Unicode codepoint in the string.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_StepUTF8. The safe import is not exported : string computation over caller memory with no allocation; cannot block, lock, or call back. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_StepUTF8, defined atSDL3/SDL_stdinc.h 4030:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> Ptr (PtrConst CChar) |
|
| -> IO Word32 |
Decode a UTF-8 string in reverse, one Unicode codepoint at a time.
This will go to the start of the previous Unicode codepoint in the string, move *pstr to that location and return that codepoint.
If *pstr is already at the start of the string), it will not advance *pstr at all.
Generally this function is called in a loop until it returns zero, adjusting its parameter each iteration.
If an invalid UTF-8 sequence is encountered, this function returns SDL_INVALID_UNICODE_CODEPOINT.
Several things can generate invalid UTF-8 sequences, including overlong encodings, the use of UTF-16 surrogate values, and truncated data. Please refer to RFC3629 for details.
- Returns
- the previous Unicode codepoint in the string.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_StepBackUTF8. The safe import is not exported : string computation over caller memory with no allocation; cannot block, lock, or call back. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_StepBackUTF8, defined atSDL3/SDL_stdinc.h 4061:36
Since: 3.2.0
Arguments
| :: Word32 |
|
| -> Ptr CChar |
|
| -> IO (Ptr CChar) |
Convert a single Unicode codepoint to UTF-8.
The buffer pointed to by dst must be at least 4 bytes long, as this function may generate between 1 and 4 bytes of output.
This function returns the first byte after the newly-written UTF-8 sequence, which is useful for encoding multiple codepoints in a loop, or knowing where to write a NULL-terminator character to end the string (in either case, plan to have a buffer of more than 4 bytes!).
If codepoint is an invalid value (outside the Unicode range, or a UTF-16 surrogate value, etc), this will use U+FFFD (REPLACEMENT CHARACTER) for the codepoint instead, and not set an error.
If dst is NULL, this returns NULL immediately without writing to the pointer and without setting an error.
- Returns
- the first byte past the newly-written UTF-8 sequence.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_UCS4ToUTF8. The safe import is not exported : string computation over caller memory with no allocation; cannot block, lock, or call back. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_UCS4ToUTF8, defined atSDL3/SDL_stdinc.h 4090:36
Since: 3.2.0
C shims
Arguments
| :: Word8 |
|
| -> Word8 |
|
| -> Word8 |
|
| -> Word8 |
|
| -> IO Word32 |
Define a four character code as a Uint32.
The SDL_FOURCC macro as a function.
- Returns
- the four characters converted into a Uint32, one character per-byte.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
lithon_SDL_FOURCC. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
lithon_SDL_FOURCC, defined atsdl3-bindgen-sys/SDL_stdinc_shims.h 40:26
Since: 3.2.0