minipix_uart_interface
A library and examples for the MiniPIX UART interface
llcp_endian.h
Go to the documentation of this file.
1 #ifndef LLCP_ENDIAN_H
2 #define LLCP_ENDIAN_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <stdint.h>
9 
10 // the "network" layer runs on BIG_ENDIAN
11 
12 #if !defined(LLCP_BIG_ENDIAN) && !defined(LLCP_LITTLE_ENDIAN)
13 #error "Must define one of LLCP_BIG_ENDIAN or LLCP_LITTLE_ENDIAN for this platform"
14 #endif
15 
16 /* Convert 16-bit number from host byte order to network byte order */
17 uint16_t __attribute__((__const__)) llcp_hton16(uint16_t h16);
18 
19 /* Convert 16-bit number from network byte order to host byte order */
20 uint16_t __attribute__((__const__)) llcp_ntoh16(uint16_t n16);
21 
22 /* Convert 32-bit number from host byte order to network byte order */
23 uint32_t __attribute__((__const__)) llcp_hton32(uint32_t h32);
24 
25 /* Convert 32-bit number from network byte order to host byte order */
26 uint32_t __attribute__((__const__)) llcp_ntoh32(uint32_t n32);
27 
28 /* Convert 64-bit number from host byte order to network byte order */
29 uint64_t __attribute__((__const__)) llcp_hton64(uint64_t h64);
30 
31 /* Convert 64-bit number from host byte order to network byte order */
32 uint64_t __attribute__((__const__)) llcp_ntoh64(uint64_t n64);
33 
34 /* Convert 16-bit number from host byte order to big endian byte order */
35 uint16_t __attribute__((__const__)) llcp_htobe16(uint16_t h16);
36 
37 /* Convert 16-bit number from host byte order to little endian byte order */
38 uint16_t __attribute__((__const__)) llcp_htole16(uint16_t h16);
39 
40 /* Convert 16-bit number from big endian byte order to little endian byte order */
41 uint16_t __attribute__((__const__)) llcp_betoh16(uint16_t be16);
42 
43 /* Convert 16-bit number from little endian byte order to host byte order */
44 uint16_t __attribute__((__const__)) llcp_letoh16(uint16_t le16);
45 
46 /* Convert 32-bit number from host byte order to big endian byte order */
47 uint32_t __attribute__((__const__)) llcp_htobe32(uint32_t h32);
48 
49 /* Convert 32-bit number from little endian byte order to host byte order */
50 uint32_t __attribute__((__const__)) llcp_htole32(uint32_t h32);
51 
52 /* Convert 32-bit number from big endian byte order to host byte order */
53 uint32_t __attribute__((__const__)) llcp_betoh32(uint32_t be32);
54 
55 /* Convert 32-bit number from little endian byte order to host byte order */
56 uint32_t __attribute__((__const__)) llcp_letoh32(uint32_t le32);
57 
58 /* Convert 64-bit number from host byte order to big endian byte order */
59 uint64_t __attribute__((__const__)) llcp_htobe64(uint64_t h64);
60 
61 /* Convert 64-bit number from host byte order to little endian byte order */
62 uint64_t __attribute__((__const__)) llcp_htole64(uint64_t h64);
63 
64 /* Convert 64-bit number from big endian byte order to host byte order */
65 uint64_t __attribute__((__const__)) llcp_betoh64(uint64_t be64);
66 
67 /* Convert 64-bit number from little endian byte order to host byte order */
68 uint64_t __attribute__((__const__)) llcp_letoh64(uint64_t le64);
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif // _H
__attribute__
uint16_t __attribute__((__const__)) llcp_hton16(uint16_t h16)
Definition: llcp_endian.c:15