Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / u32.h / u32_le.3.md

% limb manual
% u32_le(3)
% limb 0.1.0
% 2023-07-24

# NAME

u32_le, u32_be, u32p_le, u32p_be - convert an u32 to little/big endian

u32pa_le, u32pa_be - convert an array of u32 into little/big endian

# SYNOPSIS

    #include <limb/u32.h>

```pre hl
u32 u32_le(u32 <em>u</em>)
u32 u32_be(u32 <em>u</em>)

void u32p_le(u32 *<em>val</em>)
void u32p_be(u32 *<em>val</em>)

void u32pa_le(u32 *<em>val</em>, size_t <em>len</em>)
void u32pa_be(u32 *<em>val</em>, size_t <em>len</em>)
```

# DESCRIPTION

All of these aim to ensure a value or variable is in expected endianness.

The `u32_le`() and `u32_be`() macros will return the value after having read
the given number `u` as a little endian or big endian value, respectively.

The `u32p_le`() and `u32p_be`() macros are similar, only they take a pointer
to an u32 and will convert it into little endian or big endian, respectively.

Finally the `u32pa_le`() and `u32pa_be`() macros are similar to the previous
two, only they take an array of u32 of size `len` and convert every element.

! NOTE:
! Note that these are macros they may be either no-op or byte swapping functions
! depending on the endianness of the host.

# RETURN VALUE

Only `u32_le`() and `u32_be`() have a return value, that of the number `u` read
as a little or big endian number, respectively.