Debian Codegraph @

crt/aws-c-common/include/aws/common/byte_order.h

raw symbols SCIP
1 #ifndef AWS_COMMON_BYTE_ORDER_H
2 #define AWS_COMMON_BYTE_ORDER_H
3
4 /**
5 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6 * SPDX-License-Identifier: Apache-2.0.
7 */
8
9 #include <aws/common/common.h>
10
11 AWS_PUSH_SANE_WARNING_LEVEL
12 AWS_EXTERN_C_BEGIN
13
14 /**
15 * Returns 1 if machine is big endian, 0 if little endian.
16 * If you compile with even -O1 optimization, this check is completely optimized
17 * out at compile time and code which calls "if (aws_is_big_endian())" will do
18 * the right thing without branching.
19 */
20 AWS_STATIC_IMPL int aws_is_big_endian(void);
21 /**
22 * Convert 64 bit integer from host to network byte order.
23 */
24 AWS_STATIC_IMPL uint64_t aws_hton64(uint64_t x);
25 /**
26 * Convert 64 bit integer from network to host byte order.
27 */
28 AWS_STATIC_IMPL uint64_t aws_ntoh64(uint64_t x);
29
30 /**
31 * Convert 32 bit integer from host to network byte order.
32 */
33 AWS_STATIC_IMPL uint32_t aws_hton32(uint32_t x);
34
35 /**
36 * Convert 32 bit float from host to network byte order.
37 */
38 AWS_STATIC_IMPL float aws_htonf32(float x);
39
40 /**
41 * Convert 64 bit double from host to network byte order.
42 */
43 AWS_STATIC_IMPL double aws_htonf64(double x);
44
45 /**
46 * Convert 32 bit integer from network to host byte order.
47 */
48 AWS_STATIC_IMPL uint32_t aws_ntoh32(uint32_t x);
49
50 /**
51 * Convert 32 bit integer from little endian to host byte order.
52 */
53 AWS_STATIC_IMPL uint32_t aws_letoh32(uint32_t x);
54
55 /**
56 * Convert 32 bit float from network to host byte order.
57 */
58 AWS_STATIC_IMPL float aws_ntohf32(float x);
59 /**
60 * Convert 32 bit float from network to host byte order.
61 */
62 AWS_STATIC_IMPL double aws_ntohf64(double x);
63
64 /**
65 * Convert 16 bit integer from host to network byte order.
66 */
67 AWS_STATIC_IMPL uint16_t aws_hton16(uint16_t x);
68
69 /**
70 * Convert 16 bit integer from network to host byte order.
71 */
72 AWS_STATIC_IMPL uint16_t aws_ntoh16(uint16_t x);
73
74 /**
75 * Convert 16 bit integer from little endian to host byte order.
76 */
77 AWS_STATIC_IMPL uint16_t aws_letoh16(uint16_t x);
78
79 AWS_EXTERN_C_END
80 #ifndef AWS_NO_STATIC_IMPL
81 # include <aws/common/byte_order.inl>
82 #endif /* AWS_NO_STATIC_IMPL */
83
84 AWS_POP_SANE_WARNING_LEVEL
85
86 #endif /* AWS_COMMON_BYTE_ORDER_H */