Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / u16.h / u16_le.3.md

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

# NAME

u16_le, u16_be, u16p_le, u16p_be - convert an u16 to little/big endian

u16pa_le, u16pa_be - convert an array of u16 into little/big endian

# SYNOPSIS

    #include <limb/u16.h>

```pre hl
u16 u16_le(u16 <em>u</em>)
u16 u16_be(u16 <em>u</em>)

void u16p_le(u16 *<em>val</em>)
void u16p_be(u16 *<em>val</em>)

void u16pa_le(u16 *<em>val</em>, size_t <em>len</em>)
void u16pa_be(u16 *<em>val</em>, size_t <em>len</em>)
```

# DESCRIPTION

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

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

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

Finally the `u16pa_le`() and `u16pa_be`() macros are similar to the previous
two, only they take an array of u16 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 `u16_le`() and `u16_be`() have a return value, that of the number `u` read
as a little or big endian number, respectively.