Endian reads and writes: the width enum, the argument type, the five entry points and the two order tables.
More...
Go to the source code of this file.
|
| struct | EndianCfg |
| | Arguments for the endian calls, where each call reads only the members it needs. More...
|
| struct | EndianNs |
| | Type of an endian dispatch table. More...
|
|
| size_t | mmgr_wr_le (const EndianCfg *args) |
| | Writes args->width bytes of args->val to args->dst without reversing them.
|
| uint64_t | mmgr_rd_le (const EndianCfg *args) |
| | Reads args->width bytes from args->src without reversing them.
|
| size_t | mmgr_wr_be (const EndianCfg *args) |
| | Reverses args->val, then writes args->width bytes of it to args->dst.
|
| uint64_t | mmgr_rd_be (const EndianCfg *args) |
| | Reads args->width bytes from args->src, then reverses them.
|
| uint64_t | mmgr_endian_rev (const EndianCfg *args) |
| | Reverses the byte order of args->val at args->width bytes.
|
Endian reads and writes: the width enum, the argument type, the five entry points and the two order tables.
- Author
- dstroy0 (Douglas Quigg) dquig.nosp@m.g123.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
- Date
- 2026-08-29
- Note
- parva_extremitas moves bytes in the host's own order and magna_extremitas in the reverse of it. Nothing here consults MMGR_HW_BIG_ENDIAN, and so the two names hold on a little endian host and stand for the opposite orders on a big endian one.
-
The two tables share the table type and the rev entry. Their wr and rd differ, since one pair reverses and the other does not.
Definition in file endian.h.
◆ mmgr_endian_width
Width of one endian read or write, counted in bytes.
- Note
- The enumerators are the byte counts themselves, and so the implementation switches on them directly.
-
One byte on every compiler, through EMBED_ENUM_BYTE.
- Warning
- Nothing holds a value to these three. The switches in endian.c test 2 and 4 and take everything else on the default arm, which moves eight bytes.
| Enumerator |
|---|
| MMGR_ENDIAN_16 | Two bytes.
|
| MMGR_ENDIAN_32 | Four bytes.
|
| MMGR_ENDIAN_64 | Eight bytes.
|
Definition at line 38 of file endian.h.
◆ mmgr_wr_le()
Writes args->width bytes of args->val to args->dst without reversing them.
- Parameters
-
| [in,out] | args | Destination, value and width [BORROWS]. |
- Returns
- args->width.
- Warning
- args->dst must be writable for args->width bytes. Nothing checks it. endian.c hands it to proxim.put16, put32 or put64, each of which stores through it with no test.
-
args->width must be one of the mmgr_endian_width enumerators. Any other value writes eight bytes.
References mmgr_wr_le().
Referenced by mmgr_wr_le().
◆ mmgr_rd_le()
| uint64_t mmgr_rd_le |
( |
const EndianCfg * | args | ) |
|
Reads args->width bytes from args->src without reversing them.
- Parameters
-
| [in] | args | Source and width [BORROWS]. |
- Returns
- The value read, in the low args->width bytes.
- Warning
- args->src must be readable for args->width bytes. Nothing checks it. endian.c hands it to proxim.load16, load32 or load64, each of which reads through it with no test.
-
args->width must be one of the mmgr_endian_width enumerators. Any other value reads eight bytes.
References mmgr_rd_le().
Referenced by mmgr_rd_le().
◆ mmgr_wr_be()
Reverses args->val, then writes args->width bytes of it to args->dst.
- Parameters
-
| [in,out] | args | Destination, value and width [BORROWS]. |
- Returns
- args->width.
- Warning
- args->dst must be writable for args->width bytes. Nothing checks it. endian.c hands it to proxim.put16, put32 or put64, each of which stores through it with no test.
-
args->width must be one of the mmgr_endian_width enumerators. Any other value writes eight bytes. One above eight wraps the reversal's shift count, and a width of 0 shifts by 64, which is undefined.
References mmgr_wr_be().
Referenced by mmgr_wr_be().
◆ mmgr_rd_be()
| uint64_t mmgr_rd_be |
( |
const EndianCfg * | args | ) |
|
Reads args->width bytes from args->src, then reverses them.
- Parameters
-
| [in] | args | Source and width [BORROWS]. |
- Returns
- The reversed value, in the low args->width bytes.
- Warning
- args->src must be readable for args->width bytes. Nothing checks it. endian.c hands it to proxim.load16, load32 or load64, each of which reads through it with no test.
-
args->width must be one of the mmgr_endian_width enumerators. Any other value reads eight bytes. One above eight wraps the reversal's shift count, and a width of 0 shifts by 64, which is undefined.
References mmgr_rd_be().
Referenced by mmgr_rd_be().
◆ mmgr_endian_rev()
| uint64_t mmgr_endian_rev |
( |
const EndianCfg * | args | ) |
|
Reverses the byte order of args->val at args->width bytes.
- Parameters
-
| [in] | args | Value and width [BORROWS]. |
- Returns
- The reversed value, right-aligned into the low args->width bytes.
- Note
- Reads args->val and args->width, alone, and so it touches no buffer and dst and src take no part.
-
Both tables point rev at this one function, which reverses whatever it is given without reference to either order.
- Warning
- args->width must be one of the mmgr_endian_width enumerators. 8 minus it is unsigned. A width above eight wraps into a very large shift count, and a width of 0 shifts a 64-bit value by 64, which is undefined.
References mmgr_endian_rev().
Referenced by mmgr_endian_rev().
◆ parva_extremitas
Dispatch table instance named parva_extremitas, the little endian order.
- Note
- wr and rd move bytes as they lie, and so they land in the host's own order. This module never consults MMGR_HW_BIG_ENDIAN, and so the name holds on a little endian host and this table writes big endian bytes on a big endian one.
-
rev is the same function both tables use.
Definition at line 147 of file endian.h.
◆ magna_extremitas
Dispatch table instance named magna_extremitas, the big endian order.
- Note
- wr reverses before writing and rd reverses after reading, and so the bytes land in the reverse of the host's own order. That is big endian on a little endian host, as the name records, and little endian on a big endian one.
-
rev is shared with parva_extremitas.
Definition at line 161 of file endian.h.