Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlio / repo / include / nlbyteorder-little.h
1 /**
2  *    Copyright 2012-2016 Nest Labs Inc. All Rights Reserved.
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16
17 /**
18  *    @file
19  *      This file defines defines functions for performing by value
20  *      byte reordering for 16-, 32-, and 64-bit quantities both
21  *      to-and-from the target system (i.e. host) byte ordering
22  *      to-and-from both little and big endian byte ordering,
23  *      specifically for little endian target systems.
24  */
25
26 #ifndef NLBYTEORDER_LITTLE_H
27 #define NLBYTEORDER_LITTLE_H
28
29 /**
30  * This conditionally performs, as necessary for the target system, a
31  * byte order swap by value of the specified 16-bit value, presumed to
32  * be in little endian byte ordering to the target system (i.e. host)
33  * byte ordering.
34  *
35  * Consequently, on little endian target systems, this is a no-op and
36  * on big endian target systems, this performs a reordering.
37  *
38  * @param[in]  inValue  The 16-bit value to be byte order swapped.
39  *
40  * @return The input value, byte order swapped.
41  */
42 static inline uint16_t nlByteOrderSwap16LittleToHost(uint16_t inValue)
43 {
44     return inValue;
45 }
46
47 /**
48  * This conditionally performs, as necessary for the target system, a
49  * byte order swap by value of the specified 32-bit value, presumed to
50  * be in little endian byte ordering to the target system (i.e. host)
51  * byte ordering.
52  *
53  * Consequently, on little endian target systems, this is a no-op and
54  * on big endian target systems, this performs a reordering.
55  *
56  * @param[in]  inValue  The 32-bit value to be byte order swapped.
57  *
58  * @return The input value, byte order swapped.
59  */
60 static inline uint32_t nlByteOrderSwap32LittleToHost(uint32_t inValue)
61 {
62     return inValue;
63 }
64
65 /**
66  * This conditionally performs, as necessary for the target system, a
67  * byte order swap by value of the specified 64-bit value, presumed to
68  * be in little endian byte ordering to the target system (i.e. host)
69  * byte ordering.
70  *
71  * Consequently, on little endian target systems, this is a no-op and
72  * on big endian target systems, this performs a reordering.
73  *
74  * @param[in]  inValue  The 64-bit value to be byte order swapped.
75  *
76  * @return The input value, byte order swapped.
77  */
78 static inline uint64_t nlByteOrderSwap64LittleToHost(uint64_t inValue)
79 {
80     return inValue;
81 }
82
83 /**
84  * This conditionally performs, as necessary for the target system, a
85  * byte order swap by value of the specified 16-bit value, presumed to
86  * be in target system (i.e. host) byte ordering to little endian byte
87  * ordering.
88  *
89  * Consequently, on little endian target systems, this is a no-op and
90  * on big endian target systems, this performs a reordering.
91  *
92  * @param[in]  inValue  The 16-bit value to be byte order swapped.
93  *
94  * @return The input value, byte order swapped.
95  */
96 static inline uint16_t nlByteOrderSwap16HostToLittle(uint16_t inValue)
97 {
98     return inValue;
99 }
100
101 /**
102  * This conditionally performs, as necessary for the target system, a
103  * byte order swap by value of the specified 32-bit value, presumed to
104  * be in target system (i.e. host) byte ordering to little endian byte
105  * ordering.
106  *
107  * Consequently, on little endian target systems, this is a no-op and
108  * on big endian target systems, this performs a reordering.
109  *
110  * @param[in]  inValue  The 32-bit value to be byte order swapped.
111  *
112  * @return The input value, byte order swapped.
113  */
114 static inline uint32_t nlByteOrderSwap32HostToLittle(uint32_t inValue)
115 {
116     return inValue;
117 }
118
119 /**
120  * This conditionally performs, as necessary for the target system, a
121  * byte order swap by value of the specified 64-bit value, presumed to
122  * be in target system (i.e. host) byte ordering to little endian byte
123  * ordering.
124  *
125  * Consequently, on little endian target systems, this is a no-op and
126  * on big endian target systems, this performs a reordering.
127  *
128  * @param[in]  inValue  The 64-bit value to be byte order swapped.
129  *
130  * @return The input value, byte order swapped.
131  */
132 static inline uint64_t nlByteOrderSwap64HostToLittle(uint64_t inValue)
133 {
134     return inValue;
135 }
136
137 /**
138  * This conditionally performs, as necessary for the target system, a
139  * byte order swap by value of the specified 16-bit value, presumed to
140  * be in big endian byte ordering to the target system (i.e. host)
141  * byte ordering.
142  *
143  * Consequently, on little endian target systems, this performs a
144  * reordering and on big endian target systems, this is a no-op.
145  *
146  * @param[in]  inValue  The 16-bit value to be byte order swapped.
147  *
148  * @return The input value, byte order swapped.
149  */
150 static inline uint16_t nlByteOrderSwap16BigToHost(uint16_t inValue)
151 {
152     return nlByteOrderValueSwap16(inValue);
153 }
154
155 /**
156  * This conditionally performs, as necessary for the target system, a
157  * byte order swap by value of the specified 32-bit value, presumed to
158  * be in big endian byte ordering to the target system (i.e. host)
159  * byte ordering.
160  *
161  * Consequently, on little endian target systems, this performs a
162  * reordering and on big endian target systems, this is a no-op.
163  *
164  * @param[in]  inValue  The 32-bit value to be byte order swapped.
165  *
166  * @return The input value, byte order swapped.
167  */
168 static inline uint32_t nlByteOrderSwap32BigToHost(uint32_t inValue)
169 {
170     return nlByteOrderValueSwap32(inValue);
171 }
172
173 /**
174  * This conditionally performs, as necessary for the target system, a
175  * byte order swap by value of the specified 64-bit value, presumed to
176  * be in big endian byte ordering to the target system (i.e. host)
177  * byte ordering.
178  *
179  * Consequently, on little endian target systems, this performs a
180  * reordering and on big endian target systems, this is a no-op.
181  *
182  * @param[in]  inValue  The 64-bit value to be byte order swapped.
183  *
184  * @return The input value, byte order swapped.
185  */
186 static inline uint64_t nlByteOrderSwap64BigToHost(uint64_t inValue)
187 {
188     return nlByteOrderValueSwap64(inValue);
189 }
190
191 /**
192  * This conditionally performs, as necessary for the target system, a
193  * byte order swap by value of the specified 16-bit value, presumed to
194  * be in target system (i.e. host) byte ordering to big endian byte
195  * ordering.
196  *
197  * Consequently, on little endian target systems, this performs a
198  * reordering and on big endian target systems, this is a no-op.
199  *
200  * @param[in]  inValue  The 16-bit value to be byte order swapped.
201  *
202  * @return The input value, byte order swapped.
203  */
204 static inline uint16_t nlByteOrderSwap16HostToBig(uint16_t inValue)
205 {
206     return nlByteOrderValueSwap16(inValue);
207 }
208
209 /**
210  * This conditionally performs, as necessary for the target system, a
211  * byte order swap by value of the specified 32-bit value, presumed to
212  * be in target system (i.e. host) byte ordering to big endian byte
213  * ordering.
214  *
215  * Consequently, on little endian target systems, this performs a
216  * reordering and on big endian target systems, this is a no-op.
217  *
218  * @param[in]  inValue  The 32-bit value to be byte order swapped.
219  *
220  * @return The input value, byte order swapped.
221  */
222 static inline uint32_t nlByteOrderSwap32HostToBig(uint32_t inValue)
223 {
224     return nlByteOrderValueSwap32(inValue);
225 }
226
227 /**
228  * This conditionally performs, as necessary for the target system, a
229  * byte order swap by value of the specified 64-bit value, presumed to
230  * be in target system (i.e. host) byte ordering to big endian byte
231  * ordering.
232  *
233  * Consequently, on little endian target systems, this performs a
234  * reordering and on big endian target systems, this is a no-op.
235  *
236  * @param[in]  inValue  The 64-bit value to be byte order swapped.
237  *
238  * @return The input value, byte order swapped.
239  */
240 static inline uint64_t nlByteOrderSwap64HostToBig(uint64_t inValue)
241 {
242     return nlByteOrderValueSwap64(inValue);
243 }
244
245 #endif /* NLBYTEORDER_LITTLE_H */
246