include: Updated a bunch of documentation.

This commit is contained in:
Ryan C. Gordon 2024-04-13 20:10:13 -04:00
parent 3c86af5901
commit 081a94e321
No known key found for this signature in database
GPG key ID: FA148B892AB48044
3 changed files with 327 additions and 121 deletions

View file

@ -40,13 +40,6 @@ extern "C" {
* \file SDL_bits.h
*/
/**
* Get the index of the most significant bit. Result is undefined when called
* with 0. This operation can also be stated as "count leading zeroes" and
* "log base 2".
*
* \return the index of the most significant bit, or -1 if the value is 0.
*/
#if defined(__WATCOMC__) && defined(__386__)
extern __inline int _SDL_bsr_watcom(Uint32);
#pragma aux _SDL_bsr_watcom = \
@ -56,8 +49,25 @@ extern __inline int _SDL_bsr_watcom(Uint32);
modify exact [eax] nomemory;
#endif
SDL_FORCE_INLINE int
SDL_MostSignificantBitIndex32(Uint32 x)
/**
* Get the index of the most significant (set) bit in a 32-bit number.
*
* Result is undefined when called with 0. 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).
*
* \param x the 32-bit value to examine
* \returns the index of the most significant bit, or -1 if the value is 0.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0.
*/
SDL_FORCE_INLINE int SDL_MostSignificantBitIndex32(Uint32 x)
{
#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
/* Count Leading Zeroes builtin in GCC.
@ -106,8 +116,26 @@ SDL_MostSignificantBitIndex32(Uint32 x)
#endif
}
SDL_FORCE_INLINE SDL_bool
SDL_HasExactlyOneBitSet32(Uint32 x)
/**
* 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 SDL_FALSE. If any one bit is exclusively set, this returns
* SDL_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).
*
* \param x the 32-bit value to examine
* \returns SDL_TRUE if exactly one bit is set in `x`, SDL_FALSE otherwise.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0.
*/
SDL_FORCE_INLINE SDL_bool SDL_HasExactlyOneBitSet32(Uint32 x)
{
if (x && !(x & (x - 1))) {
return SDL_TRUE;