Merge branch 'endian-docs' into 'master'
add descriptions to endian functions See merge request redox-os/relibc!1365
This commit is contained in:
@@ -7,6 +7,5 @@ sys_includes = ["stdint.h"]
|
||||
include_guard = "_RELIBC_ENDIAN_H"
|
||||
trailer = "#include <machine/endian.h>"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
no_includes = true
|
||||
cpp_compat = true
|
||||
|
||||
@@ -5,72 +5,108 @@
|
||||
use crate::platform::types::{uint16_t, uint32_t, uint64_t};
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint16_t` from big endian representation to host endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn be16toh(x: uint16_t) -> uint16_t {
|
||||
uint16_t::from_be(x)
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint32_t` from big endian representation to host endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn be32toh(x: uint32_t) -> uint32_t {
|
||||
uint32_t::from_be(x)
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint64_t` from big endian representation to host endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn be64toh(x: uint64_t) -> uint64_t {
|
||||
uint64_t::from_be(x)
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint16_t` from host endian representation to big endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn htobe16(x: uint16_t) -> uint16_t {
|
||||
x.to_be()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint32_t` from host endian representation to big endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn htobe32(x: uint32_t) -> uint32_t {
|
||||
x.to_be()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint64_t` from host endian representation to big endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn htobe64(x: uint64_t) -> uint64_t {
|
||||
x.to_be()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint16_t` from host endian representation to little endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn htole16(x: uint16_t) -> uint16_t {
|
||||
x.to_le()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint32_t` from host endian representation to little endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn htole32(x: uint32_t) -> uint32_t {
|
||||
x.to_le()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint64_t` from host endian representation to little endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn htole64(x: uint64_t) -> uint64_t {
|
||||
x.to_le()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint16_t` from little endian representation to host endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn le16toh(x: uint16_t) -> uint16_t {
|
||||
uint16_t::from_le(x)
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint32_t` from little endian representation to host endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn le32toh(x: uint32_t) -> uint32_t {
|
||||
uint32_t::from_le(x)
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/be16toh.html>.
|
||||
///
|
||||
/// Convert a `uint64_t` from little endian representation to host endian
|
||||
/// respresentation.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn le64toh(x: uint64_t) -> uint64_t {
|
||||
uint64_t::from_le(x)
|
||||
|
||||
Reference in New Issue
Block a user