8 #ifndef _RTEMS_ENDIAN_H 9 #define _RTEMS_ENDIAN_H 13 #include <machine/endian.h> 15 #ifndef _BYTEORDER_FUNC_DEFINED 16 #define _BYTEORDER_FUNC_DEFINED 17 #define htonl(x) __htonl(x) 18 #define htons(x) __htons(x) 19 #define ntohl(x) __ntohl(x) 20 #define ntohs(x) __ntohs(x) 23 #define NTOHS(x) (x) = ntohs(x) 24 #define HTONS(x) (x) = htons(x) 25 #define NTOHL(x) (x) = ntohl(x) 26 #define HTONL(x) (x) = htonl(x) 28 static inline uint16_t rtems_uint16_from_little_endian(
const uint8_t *data)
33 for (i = 1; i >= 0; --i) {
34 value = (uint16_t) ((value << 8) + data [i]);
40 static inline uint32_t rtems_uint32_from_little_endian(
const uint8_t *data)
45 for (i = 3; i >= 0; --i) {
46 value = (value << 8) + data [i];
52 static inline uint64_t rtems_uint64_from_little_endian(
const uint8_t *data)
57 for (i = 7; i >= 0; --i) {
58 value = (value << 8) + (uint64_t) data [i];
64 static inline uint16_t rtems_uint16_from_big_endian(
const uint8_t *data)
69 for (i = 0; i < 2; ++i) {
70 value = (uint16_t) ((value << 8) + data [i]);
76 static inline uint32_t rtems_uint32_from_big_endian(
const uint8_t *data)
81 for (i = 0; i < 4; ++i) {
82 value = (value << 8) + (uint32_t) data [i];
88 static inline uint64_t rtems_uint64_from_big_endian(
const uint8_t *data)
93 for (i = 0; i < 8; ++i) {
94 value = (value << 8) + (uint64_t) data [i];
100 static inline void rtems_uint16_to_little_endian( uint16_t value, uint8_t *data)
104 for (i = 0; i < 2; ++i) {
105 data [i] = (uint8_t) value;
110 static inline void rtems_uint32_to_little_endian( uint32_t value, uint8_t *data)
114 for (i = 0; i < 4; ++i) {
115 data [i] = (uint8_t) value;
120 static inline void rtems_uint64_to_little_endian( uint64_t value, uint8_t *data)
124 for (i = 0; i < 8; ++i) {
125 data [i] = (uint8_t) value;
130 static inline void rtems_uint16_to_big_endian( uint16_t value, uint8_t *data)
134 for (i = 1; i >= 0; --i) {
135 data [i] = (uint8_t) value;
140 static inline void rtems_uint32_to_big_endian( uint32_t value, uint8_t *data)
144 for (i = 3; i >= 0; --i) {
145 data [i] = (uint8_t) value;
150 static inline void rtems_uint64_to_big_endian( uint64_t value, uint8_t *data)
154 for (i = 7; i >= 0; --i) {
155 data [i] = (uint8_t) value;