| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Bits
Contents
Description
Functions for fiddling with bits and bitmasks. Get the index of the most significant (set) bit in a 32-bit number.
This operation can also be stated as "count leading zeroes" and "log base 2".
Note that this is a forced-inline function in a header, and not a public API function available in the SDL library (which is to say, the code is embedded in the calling program and the linker and dynamic loader will not be able to find this function inside SDL itself).
x- the 32-bit value to examine.
- Returns
- the index of the most significant bit, or -1 if the value is 0.
- Thread safety
- It is safe to call this function from any thread.
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.Bits.Unsafe); functions curated unsafe-only export only the unsuffixed one. Each alias's documentation records its flavor and rationale.
Full conventions: SDL3.Sys.
Since: 3.2.0
Synopsis
Function aliases
mostSignificantBitIndex32 Source #
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_MostSignificantBitIndex32. The safe flavor ismostSignificantBitIndex32Safe. - 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_MostSignificantBitIndex32, defined atSDL3/SDL_bits.h 65:22
mostSignificantBitIndex32Safe Source #
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_MostSignificantBitIndex32. The unsafe flavor ismostSignificantBitIndex32. - 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_MostSignificantBitIndex32, defined atSDL3/SDL_bits.h 65:22
hasExactlyOneBitSet32 Source #
Determine if a unsigned 32-bit value has exactly one bit set.
If there are no bits set (x is zero), or more than one bit set, this returns false. If any one bit is exclusively set, this returns true.
Note that this is a forced-inline function in a header, and not a public API function available in the SDL library (which is to say, the code is embedded in the calling program and the linker and dynamic loader will not be able to find this function inside SDL itself).
- Returns
- true if exactly one bit is set in
x, false otherwise. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_HasExactlyOneBitSet32. The safe flavor ishasExactlyOneBitSet32Safe. - 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_HasExactlyOneBitSet32, defined atSDL3/SDL_bits.h 132:23
Since: 3.2.0
hasExactlyOneBitSet32Safe Source #
Determine if a unsigned 32-bit value has exactly one bit set.
If there are no bits set (x is zero), or more than one bit set, this returns false. If any one bit is exclusively set, this returns true.
Note that this is a forced-inline function in a header, and not a public API function available in the SDL library (which is to say, the code is embedded in the calling program and the linker and dynamic loader will not be able to find this function inside SDL itself).
- Returns
- true if exactly one bit is set in
x, false otherwise. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_HasExactlyOneBitSet32. The unsafe flavor ishasExactlyOneBitSet32. - 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_HasExactlyOneBitSet32, defined atSDL3/SDL_bits.h 132:23
Since: 3.2.0