ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
endian.h
Go to the documentation of this file.
1
49
50#pragma once
51
52#include <stdint.h>
53
54/*
55 * The build must be little-endian for the bodies below to be correct. GCC and
56 * clang both define __BYTE_ORDER__ and __ORDER_LITTLE_ENDIAN__; if a toolchain
57 * ever arrives that does not, the first branch fails loudly rather than letting
58 * the second one assume anything.
59 */
60#if !defined(__BYTE_ORDER__) || !defined(__ORDER_LITTLE_ENDIAN__)
61#error "endian.h: toolchain does not report __BYTE_ORDER__; cannot prove byte order"
62#endif
63
64static_assert(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__,
65 "esp-hosted framing assumes a little-endian host; see this file's @details");
66
67/* The four function spellings below are fixed by the BSD / glibc <endian.h>
68 contract that the vendored transport drivers are written against, so they
69 cannot take this project's ra8_ prefix. clang-tidy's naming rule is
70 suppressed across the block, following the ThreadX shim precedent in
71 libs/ra8_wdt_supervisor and the sibling esp_log.h. */
72
111static inline uint16_t htole16(uint16_t host_value)
112{
113 return host_value;
114}
115
152static inline uint16_t le16toh(uint16_t wire_value)
153{
154 return wire_value;
155}
156
193static inline uint32_t htole32(uint32_t host_value)
194{
195 return host_value;
196}
197
233static inline uint32_t le32toh(uint32_t wire_value)
234{
235 return wire_value;
236}
static uint32_t le32toh(uint32_t wire_value)
Convert a 32-bit value from little-endian wire order to host order.
Definition endian.h:233
static uint32_t htole32(uint32_t host_value)
Convert a 32-bit value from host order to little-endian wire order.
Definition endian.h:193
static uint16_t htole16(uint16_t host_value)
Convert a 16-bit value from host order to little-endian wire order.
Definition endian.h:111
static uint16_t le16toh(uint16_t wire_value)
Convert a 16-bit value from little-endian wire order to host order.
Definition endian.h:152