Module dslib:endian_helpers
Helper functions for endianness.
Functions
| get_endian () | Returns the native endian-ness of the system. |
| Xe_to_Ye (num) | Converts a number from one endian-ness to another. |
| to_le (num) | Alias for ne_to_le(). |
| to_be (num) | Alias for ne_to_be(). |
| from_le (num) | Alias for le_to_ne(). |
| from_be (num) | Alias for be_to_ne(). |
| identity (num) | Alias for ne_to_ne() and similar (identity). |
| bswap (num) | Alias for le_to_be() and be_to_le() (bit.bswap). |
Functions
- get_endian () line 58
-
Returns the native endian-ness of the system.
Returns:
"little"for little-endian,"big"for big-endian. Anything else is not supported. - Xe_to_Ye (num) line 81
-
Converts a number from one endian-ness to another.
XandYcan be any ofn,landb, for native-, little- and big endian-ness respectively.The numbers can also be LuaJIT 64 bit cdata numbers.
If a number is used, it may be interpreted as signed 32-bit integer. (
bit.bswapis used.)TODO: Auto-create doc for all, instead of the templates in the name.
Parameters:
- num
int
The number to convert in endian-ness
X.
Returns:
-
int
The number in endian-ness
Y. - num
int
The number to convert in endian-ness
- to_le (num) line 95
-
Alias for
ne_to_le().Parameters:
- num int
Returns:
-
int
- to_be (num) line 100
-
Alias for
ne_to_be().Parameters:
- num int
Returns:
-
int
- from_le (num) line 105
-
Alias for
le_to_ne().Parameters:
- num int
Returns:
-
int
- from_be (num) line 110
-
Alias for
be_to_ne().Parameters:
- num int
Returns:
-
int
- identity (num) line 116
-
Alias for
ne_to_ne()and similar (identity).Parameters:
- num int
Returns:
-
int
- bswap (num) line 121
-
Alias for
le_to_be()andbe_to_le()(bit.bswap).Parameters:
- num int
Returns:
-
int