Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlio / repo / include / nlio-byteorder-big.h
1 /**
2  *    Copyright 2013-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 C functions for safely performing simple,
20  *      memory-mapped accesses, potentially to unaligned, aligned, and
21  *      unaligned memory locations with byte reordering, specifically
22  *      for big endian target systems.
23  */
24
25 #ifndef NLIO_BYTEORDER_BIG_H
26 #define NLIO_BYTEORDER_BIG_H
27
28 #include <nlio-base.h>
29 #include <nlbyteorder.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36  * Perform a, potentially unaligned, memory read of the big endian
37  * byte ordered 8-bit value from the specified pointer address,
38  * perform byte reordering, as necessary, for the target system to
39  * put the value in target system byte ordering.
40  *
41  * @param[in]  p      A pointer address, potentially unaligned, to read
42  *                    the 8-bit big endian byte ordered value from.
43  *
44  * @return The 8-bit value at the specified pointer address.
45  */
46 static inline uint8_t  nlIOBigEndianGet8(const void *p)
47 {
48     return nlIOGet8(p);
49 }
50
51 /**
52  * Perform a, potentially unaligned, memory read of the big endian
53  * byte ordered 16-bit value from the specified pointer address,
54  * perform byte reordering, as necessary, for the target system to
55  * put the value in target system byte ordering.
56  *
57  * @param[in]  p      A pointer address, potentially unaligned, to read
58  *                    the 16-bit big endian byte ordered value from.
59  *
60  * @return The 16-bit value at the specified pointer address.
61  */
62 static inline uint16_t nlIOBigEndianGet16(const void *p)
63 {
64     return nlByteOrderSwap16BigToHost(nlIOGet16(p));
65 }
66
67 /**
68  * Perform a, potentially unaligned, memory read of the big endian
69  * byte ordered 32-bit value from the specified pointer address,
70  * perform byte reordering, as necessary, for the target system to
71  * put the value in target system byte ordering.
72  *
73  * @param[in]  p      A pointer address, potentially unaligned, to read
74  *                    the 32-bit big endian byte ordered value from.
75  *
76  * @return The 32-bit value at the specified pointer address.
77  */
78 static inline uint32_t nlIOBigEndianGet32(const void *p)
79 {
80     return nlByteOrderSwap32BigToHost(nlIOGet32(p));
81 }
82
83 /**
84  * Perform a, potentially unaligned, memory read of the big endian
85  * byte ordered 64-bit value from the specified pointer address,
86  * perform byte reordering, as necessary, for the target system to
87  * put the value in target system byte ordering.
88  *
89  * @param[in]  p      A pointer address, potentially unaligned, to read
90  *                    the 64-bit big endian byte ordered value from.
91  *
92  * @return The 64-bit value at the specified pointer address.
93  */
94 static inline uint64_t nlIOBigEndianGet64(const void *p)
95 {
96     return nlByteOrderSwap64BigToHost(nlIOGet64(p));
97 }
98
99 /**
100  * Perform a, potentially unaligned, memory write of the target system
101  * byte ordered 8-bit value to the specified pointer address,
102  * perform byte reordering, as necessary, for the target system to
103  * put the value in big endian byte ordering.
104  *
105  * @param[in]  p      A pointer address, potentially unaligned, to write
106  *                    the target system byte ordered 8-bit value to in big
107  *                    endian byte ordering.
108  *
109  * @param[in]  v      The 8-bit value to write.
110  *
111  */
112 static inline void     nlIOBigEndianPut8(void *p, uint8_t v)
113 {
114     nlIOPut8(p, v);
115 }
116
117 /**
118  * Perform a, potentially unaligned, memory write of the target system
119  * byte ordered 16-bit value to the specified pointer address,
120  * perform byte reordering, as necessary, for the target system to
121  * put the value in big endian byte ordering.
122  *
123  * @param[in]  p      A pointer address, potentially unaligned, to write
124  *                    the target system byte ordered 16-bit value to in big
125  *                    endian byte ordering.
126  *
127  * @param[in]  v      The 16-bit value to write.
128  *
129  */
130 static inline void     nlIOBigEndianPut16(void *p, uint16_t v)
131 {
132     nlIOPut16(p, nlByteOrderSwap16HostToBig(v));
133 }
134
135 /**
136  * Perform a, potentially unaligned, memory write of the target system
137  * byte ordered 32-bit value to the specified pointer address,
138  * perform byte reordering, as necessary, for the target system to
139  * put the value in big endian byte ordering.
140  *
141  * @param[in]  p      A pointer address, potentially unaligned, to write
142  *                    the target system byte ordered 32-bit value to in big
143  *                    endian byte ordering.
144  *
145  * @param[in]  v      The 32-bit value to write.
146  *
147  */
148 static inline void     nlIOBigEndianPut32(void *p, uint32_t v)
149 {
150     nlIOPut32(p, nlByteOrderSwap32HostToBig(v));
151 }
152
153 /**
154  * Perform a, potentially unaligned, memory write of the target system
155  * byte ordered 64-bit value to the specified pointer address,
156  * perform byte reordering, as necessary, for the target system to
157  * put the value in big endian byte ordering.
158  *
159  * @param[in]  p      A pointer address, potentially unaligned, to write
160  *                    the target system byte ordered 64-bit value to in big
161  *                    endian byte ordering.
162  *
163  * @param[in]  v      The 64-bit value to write.
164  *
165  */
166 static inline void     nlIOBigEndianPut64(void *p, uint64_t v)
167 {
168     nlIOPut64(p, nlByteOrderSwap64HostToBig(v));
169 }
170
171 /**
172  * Perform a, potentially unaligned, memory read of the big endian
173  * byte ordered 8-bit value from the specified pointer address,
174  * perform byte reordering, as necessary, for the target system to put
175  * the value in target system byte ordering, and increment the pointer
176  * by 8-bits (1 byte).
177  *
178  * @param[inout]  p   A pointer to a pointer address, potentially
179  *                    unaligned, to read the 8-bit big endian byte
180  *                    ordered value from and to then increment by 8-
181  *                    bits (1 byte).
182  *
183  * @return The 8-bit value at the specified pointer address.
184  */
185 static inline uint8_t  nlIOBigEndianRead8(const void **p)
186 {
187     return nlIORead8(p);
188 }
189
190 /**
191  * Perform a, potentially unaligned, memory read of the big endian
192  * byte ordered 16-bit value from the specified pointer address,
193  * perform byte reordering, as necessary, for the target system to put
194  * the value in target system byte ordering, and increment the pointer
195  * by 16-bits (2 bytes).
196  *
197  * @param[inout]  p   A pointer to a pointer address, potentially
198  *                    unaligned, to read the 16-bit big endian byte
199  *                    ordered value from and to then increment by 16-
200  *                    bits (2 bytes).
201  *
202  * @return The 16-bit value at the specified pointer address.
203  */
204 static inline uint16_t nlIOBigEndianRead16(const void **p)
205 {
206     return nlByteOrderSwap16BigToHost(nlIORead16(p));
207 }
208
209 /**
210  * Perform a, potentially unaligned, memory read of the big endian
211  * byte ordered 32-bit value from the specified pointer address,
212  * perform byte reordering, as necessary, for the target system to put
213  * the value in target system byte ordering, and increment the pointer
214  * by 32-bits (4 bytes).
215  *
216  * @param[inout]  p   A pointer to a pointer address, potentially
217  *                    unaligned, to read the 32-bit big endian byte
218  *                    ordered value from and to then increment by 32-
219  *                    bits (4 bytes).
220  *
221  * @return The 32-bit value at the specified pointer address.
222  */
223 static inline uint32_t nlIOBigEndianRead32(const void **p)
224 {
225     return nlByteOrderSwap32BigToHost(nlIORead32(p));
226 }
227
228 /**
229  * Perform a, potentially unaligned, memory read of the big endian
230  * byte ordered 64-bit value from the specified pointer address,
231  * perform byte reordering, as necessary, for the target system to put
232  * the value in target system byte ordering, and increment the pointer
233  * by 64-bits (8 bytes).
234  *
235  * @param[inout]  p   A pointer to a pointer address, potentially
236  *                    unaligned, to read the 64-bit big endian byte
237  *                    ordered value from and to then increment by 64-
238  *                    bits (8 bytes).
239  *
240  * @return The 64-bit value at the specified pointer address.
241  */
242 static inline uint64_t nlIOBigEndianRead64(const void **p)
243 {
244     return nlByteOrderSwap64BigToHost(nlIORead64(p));
245 }
246
247 /**
248  * Perform a, potentially unaligned, memory write of the target system
249  * byte ordered 8-bit value to the specified pointer address,
250  * perform byte reordering, as necessary, for the target system to
251  * put the value in big endian byte ordering.
252  *
253  * @param[in]  p      A pointer to a pointer address, potentially
254  *                    unaligned, to write the target system byte
255  *                    ordered 8-bit value to in big endian byte
256  *                    ordering and to then increment by 8-bits (1
257  *                    byte).
258  *
259  * @param[in]  v      The 8-bit value to write.
260  *
261  */
262 static inline void     nlIOBigEndianWrite8(void **p, uint8_t v)
263 {
264     nlIOWrite8(p, v);
265 }
266
267 /**
268  * Perform a, potentially unaligned, memory write of the target system
269  * byte ordered 16-bit value to the specified pointer address,
270  * perform byte reordering, as necessary, for the target system to
271  * put the value in big endian byte ordering.
272  *
273  * @param[in]  p      A pointer to a pointer address, potentially
274  *                    unaligned, to write the target system byte
275  *                    ordered 16-bit value to in big endian byte
276  *                    ordering and to then increment by 16-bits (2
277  *                    bytes).
278  *
279  * @param[in]  v      The 16-bit value to write.
280  *
281  */
282 static inline void     nlIOBigEndianWrite16(void **p, uint16_t v)
283 {
284     nlIOWrite16(p, nlByteOrderSwap16HostToBig(v));
285 }
286
287 /**
288  * Perform a, potentially unaligned, memory write of the target system
289  * byte ordered 32-bit value to the specified pointer address,
290  * perform byte reordering, as necessary, for the target system to
291  * put the value in big endian byte ordering.
292  *
293  * @param[in]  p      A pointer to a pointer address, potentially
294  *                    unaligned, to write the target system byte
295  *                    ordered 32-bit value to in big endian byte
296  *                    ordering and to then increment by 16-bits (4
297  *                    bytes).
298  *
299  * @param[in]  v      The 32-bit value to write.
300  *
301  */
302 static inline void     nlIOBigEndianWrite32(void **p, uint32_t v)
303 {
304     nlIOWrite32(p, nlByteOrderSwap32HostToBig(v));
305 }
306
307 /**
308  * Perform a, potentially unaligned, memory write of the target system
309  * byte ordered 64-bit value to the specified pointer address,
310  * perform byte reordering, as necessary, for the target system to
311  * put the value in big endian byte ordering.
312  *
313  * @param[in]  p      A pointer to a pointer address, potentially
314  *                    unaligned, to write the target system byte
315  *                    ordered 64-bit value to in big endian byte
316  *                    ordering and to then increment by 64-bits (8
317  *                    bytes).
318  *
319  * @param[in]  v      The 64-bit value to write.
320  *
321  */
322 static inline void     nlIOBigEndianWrite64(void **p, uint64_t v)
323 {
324     nlIOWrite64(p, nlByteOrderSwap64HostToBig(v));
325 }
326
327 /**
328  * Perform an aligned memory read of the big endian
329  * byte ordered 8-bit value from the specified pointer address,
330  * perform byte reordering, as necessary, for the target system to
331  * put the value in target system byte ordering.
332  *
333  * @param[in]  p      An aligned pointer address to read
334  *                    the 8-bit big endian byte ordered value from.
335  *
336  * @return The 8-bit value at the specified pointer address.
337  */
338 static inline uint8_t  nlIOBigEndianGetAligned8(const void *p)
339 {
340     return nlIOGetAligned8(p);
341 }
342
343 /**
344  * Perform an aligned memory read of the big endian
345  * byte ordered 16-bit value from the specified pointer address,
346  * perform byte reordering, as necessary, for the target system to
347  * put the value in target system byte ordering.
348  *
349  * @param[in]  p      An aligned pointer address to read
350  *                    the 16-bit big endian byte ordered value from.
351  *
352  * @return The 16-bit value at the specified pointer address.
353  */
354 static inline uint16_t nlIOBigEndianGetAligned16(const void *p)
355 {
356     return nlByteOrderSwap16BigToHost(nlIOGetAligned16(p));
357 }
358
359 /**
360  * Perform an aligned memory read of the big endian
361  * byte ordered 32-bit value from the specified pointer address,
362  * perform byte reordering, as necessary, for the target system to
363  * put the value in target system byte ordering.
364  *
365  * @param[in]  p      An aligned pointer address to read
366  *                    the 32-bit big endian byte ordered value from.
367  *
368  * @return The 32-bit value at the specified pointer address.
369  */
370 static inline uint32_t nlIOBigEndianGetAligned32(const void *p)
371 {
372     return nlByteOrderSwap32BigToHost(nlIOGetAligned32(p));
373 }
374
375 /**
376  * Perform an aligned memory read of the big endian
377  * byte ordered 64-bit value from the specified pointer address,
378  * perform byte reordering, as necessary, for the target system to
379  * put the value in target system byte ordering.
380  *
381  * @param[in]  p      An aligned pointer address to read
382  *                    the 64-bit big endian byte ordered value from.
383  *
384  * @return The 64-bit value at the specified pointer address.
385  */
386 static inline uint64_t nlIOBigEndianGetAligned64(const void *p)
387 {
388     return nlByteOrderSwap64BigToHost(nlIOGetAligned64(p));
389 }
390
391 /**
392  * Perform an aligned memory write of the target system
393  * byte ordered 8-bit value to the specified pointer address,
394  * perform byte reordering, as necessary, for the target system to
395  * put the value in big endian byte ordering.
396  *
397  * @param[in]  p      An aligned pointer address to write
398  *                    the target system byte ordered 8-bit value to in big
399  *                    endian byte ordering.
400  *
401  * @param[in]  v      The 8-bit value to write.
402  *
403  */
404 static inline void     nlIOBigEndianPutAligned8(void *p, uint8_t v)
405 {
406     nlIOPutAligned8(p, v);
407 }
408
409 /**
410  * Perform an aligned memory write of the target system
411  * byte ordered 16-bit value to the specified pointer address,
412  * perform byte reordering, as necessary, for the target system to
413  * put the value in big endian byte ordering.
414  *
415  * @param[in]  p      An aligned pointer address to write
416  *                    the target system byte ordered 16-bit value to in big
417  *                    endian byte ordering.
418  *
419  * @param[in]  v      The 16-bit value to write.
420  *
421  */
422 static inline void     nlIOBigEndianPutAligned16(void *p, uint16_t v)
423 {
424     nlIOPutAligned16(p, nlByteOrderSwap16HostToBig(v));
425 }
426
427 /**
428  * Perform an aligned memory write of the target system
429  * byte ordered 32-bit value to the specified pointer address,
430  * perform byte reordering, as necessary, for the target system to
431  * put the value in big endian byte ordering.
432  *
433  * @param[in]  p      An aligned pointer address to write
434  *                    the target system byte ordered 32-bit value to in big
435  *                    endian byte ordering.
436  *
437  * @param[in]  v      The 32-bit value to write.
438  *
439  */
440 static inline void     nlIOBigEndianPutAligned32(void *p, uint32_t v)
441 {
442     nlIOPutAligned32(p, nlByteOrderSwap32HostToBig(v));
443 }
444
445 /**
446  * Perform an aligned memory write of the target system
447  * byte ordered 64-bit value to the specified pointer address,
448  * perform byte reordering, as necessary, for the target system to
449  * put the value in big endian byte ordering.
450  *
451  * @param[in]  p      An aligned pointer address to write
452  *                    the target system byte ordered 64-bit value to in big
453  *                    endian byte ordering.
454  *
455  * @param[in]  v      The 64-bit value to write.
456  *
457  */
458 static inline void     nlIOBigEndianPutAligned64(void *p, uint64_t v)
459 {
460     nlIOPutAligned64(p, nlByteOrderSwap64HostToBig(v));
461 }
462
463 /**
464  * Perform an aligned memory read of the big endian
465  * byte ordered 8-bit value from the specified pointer address,
466  * perform byte reordering, as necessary, for the target system to put
467  * the value in target system byte ordering, and increment the pointer
468  * by 8-bits (1 byte).
469  *
470  * @param[inout]  p   A pointer to an aligned pointer address, 
471  *                    to read the 8-bit big endian byte
472  *                    ordered value from and to then increment by 8-
473  *                    bits (1 byte).
474  *
475  * @return The 8-bit value at the specified pointer address.
476  */
477 static inline uint8_t  nlIOBigEndianReadAligned8(const void **p)
478 {
479     return nlIOReadAligned8(p);
480 }
481
482 /**
483  * Perform an aligned memory read of the big endian
484  * byte ordered 16-bit value from the specified pointer address,
485  * perform byte reordering, as necessary, for the target system to put
486  * the value in target system byte ordering, and increment the pointer
487  * by 16-bits (2 bytes).
488  *
489  * @param[inout]  p   A pointer to an aligned pointer address, 
490  *                    to read the 16-bit big endian byte
491  *                    ordered value from and to then increment by 16-
492  *                    bits (2 bytes).
493  *
494  * @return The 16-bit value at the specified pointer address.
495  */
496 static inline uint16_t nlIOBigEndianReadAligned16(const void **p)
497 {
498     return nlByteOrderSwap16BigToHost(nlIOReadAligned16(p));
499 }
500
501 /**
502  * Perform an aligned memory read of the big endian
503  * byte ordered 32-bit value from the specified pointer address,
504  * perform byte reordering, as necessary, for the target system to put
505  * the value in target system byte ordering, and increment the pointer
506  * by 32-bits (4 bytes).
507  *
508  * @param[inout]  p   A pointer to an aligned pointer address, 
509  *                    to read the 32-bit big endian byte
510  *                    ordered value from and to then increment by 32-
511  *                    bits (4 bytes).
512  *
513  * @return The 32-bit value at the specified pointer address.
514  */
515 static inline uint32_t nlIOBigEndianReadAligned32(const void **p)
516 {
517     return nlByteOrderSwap32BigToHost(nlIOReadAligned32(p));
518 }
519
520 /**
521  * Perform an aligned memory read of the big endian
522  * byte ordered 64-bit value from the specified pointer address,
523  * perform byte reordering, as necessary, for the target system to put
524  * the value in target system byte ordering, and increment the pointer
525  * by 64-bits (8 bytes).
526  *
527  * @param[inout]  p   A pointer to an aligned pointer address, 
528  *                    to read the 64-bit big endian byte
529  *                    ordered value from and to then increment by 64-
530  *                    bits (8 bytes).
531  *
532  * @return The 64-bit value at the specified pointer address.
533  */
534 static inline uint64_t nlIOBigEndianReadAligned64(const void **p)
535 {
536     return nlByteOrderSwap64BigToHost(nlIOReadAligned64(p));
537 }
538
539 /**
540  * Perform an aligned memory write of the target system
541  * byte ordered 8-bit value to the specified pointer address,
542  * perform byte reordering, as necessary, for the target system to
543  * put the value in big endian byte ordering.
544  *
545  * @param[inout]  p   A pointer to an aligned pointer address, 
546  *                    to write the target system byte
547  *                    ordered 8-bit value to in big endian byte
548  *                    ordering and to then increment by 8-bits (1
549  *                    byte).
550  *
551  * @param[in]  v      The 8-bit value to write.
552  *
553  */
554 static inline void     nlIOBigEndianWriteAligned8(void **p, uint8_t v)
555 {
556     nlIOWriteAligned8(p, v);
557 }
558
559 /**
560  * Perform an aligned memory write of the target system
561  * byte ordered 16-bit value to the specified pointer address,
562  * perform byte reordering, as necessary, for the target system to
563  * put the value in big endian byte ordering.
564  *
565  * @param[inout]  p   A pointer to an aligned pointer address, 
566  *                    to write the target system byte
567  *                    ordered 16-bit value to in big endian byte
568  *                    ordering and to then increment by 16-bits (2
569  *                    bytes).
570  *
571  * @param[in]  v      The 16-bit value to write.
572  *
573  */
574 static inline void     nlIOBigEndianWriteAligned16(void **p, uint16_t v)
575 {
576     nlIOWriteAligned16(p, nlByteOrderSwap16HostToBig(v));
577 }
578
579 /**
580  * Perform an aligned memory write of the target system
581  * byte ordered 32-bit value to the specified pointer address,
582  * perform byte reordering, as necessary, for the target system to
583  * put the value in big endian byte ordering.
584  *
585  * @param[inout]  p   A pointer to an aligned pointer address, 
586  *                    to write the target system byte
587  *                    ordered 32-bit value to in big endian byte
588  *                    ordering and to then increment by 16-bits (4
589  *                    bytes).
590  *
591  * @param[in]  v      The 32-bit value to write.
592  *
593  */
594 static inline void     nlIOBigEndianWriteAligned32(void **p, uint32_t v)
595 {
596     nlIOWriteAligned32(p, nlByteOrderSwap32HostToBig(v));
597 }
598
599 /**
600  * Perform an aligned memory write of the target system
601  * byte ordered 64-bit value to the specified pointer address,
602  * perform byte reordering, as necessary, for the target system to
603  * put the value in big endian byte ordering.
604  *
605  * @param[inout]  p   A pointer to an aligned pointer address, 
606  *                    to write the target system byte
607  *                    ordered 64-bit value to in big endian byte
608  *                    ordering and to then increment by 64-bits (8
609  *                    bytes).
610  *
611  * @param[in]  v      The 64-bit value to write.
612  *
613  */
614 static inline void     nlIOBigEndianWriteAligned64(void **p, uint64_t v)
615 {
616     nlIOWriteAligned64(p, nlByteOrderSwap64HostToBig(v));
617 }
618
619 /**
620  * Perform an unaligned memory read of the big endian
621  * byte ordered 8-bit value from the specified pointer address,
622  * perform byte reordering, as necessary, for the target system to
623  * put the value in target system byte ordering.
624  *
625  * @param[in]  p      An unaligned pointer address to read
626  *                    the 8-bit big endian byte ordered value from.
627  *
628  * @return The 8-bit value at the specified pointer address.
629  */
630 static inline uint8_t  nlIOBigEndianGetUnaligned8(const void *p)
631 {
632     return nlIOGetUnaligned8(p);
633 }
634
635 /**
636  * Perform an unaligned memory read of the big endian
637  * byte ordered 16-bit value from the specified pointer address,
638  * perform byte reordering, as necessary, for the target system to
639  * put the value in target system byte ordering.
640  *
641  * @param[in]  p      An unaligned pointer address to read
642  *                    the 16-bit big endian byte ordered value from.
643  *
644  * @return The 16-bit value at the specified pointer address.
645  */
646 static inline uint16_t nlIOBigEndianGetUnaligned16(const void *p)
647 {
648     return nlByteOrderSwap16BigToHost(nlIOGetUnaligned16(p));
649 }
650
651 /**
652  * Perform an unaligned memory read of the big endian
653  * byte ordered 32-bit value from the specified pointer address,
654  * perform byte reordering, as necessary, for the target system to
655  * put the value in target system byte ordering.
656  *
657  * @param[in]  p      An unaligned pointer address to read
658  *                    the 32-bit big endian byte ordered value from.
659  *
660  * @return The 32-bit value at the specified pointer address.
661  */
662 static inline uint32_t nlIOBigEndianGetUnaligned32(const void *p)
663 {
664     return nlByteOrderSwap32BigToHost(nlIOGetUnaligned32(p));
665 }
666
667 /**
668  * Perform an unaligned memory read of the big endian
669  * byte ordered 64-bit value from the specified pointer address,
670  * perform byte reordering, as necessary, for the target system to
671  * put the value in target system byte ordering.
672  *
673  * @param[in]  p      An unaligned pointer address to read
674  *                    the 64-bit big endian byte ordered value from.
675  *
676  * @return The 64-bit value at the specified pointer address.
677  */
678 static inline uint64_t nlIOBigEndianGetUnaligned64(const void *p)
679 {
680     return nlByteOrderSwap64BigToHost(nlIOGetUnaligned64(p));
681 }
682
683 /**
684  * Perform an unaligned memory write of the target system
685  * byte ordered 8-bit value to the specified pointer address,
686  * perform byte reordering, as necessary, for the target system to
687  * put the value in big endian byte ordering.
688  *
689  * @param[in]  p      An unaligned pointer address to write
690  *                    the target system byte ordered 8-bit value to in big
691  *                    endian byte ordering.
692  *
693  * @param[in]  v      The 8-bit value to write.
694  *
695  */
696 static inline void     nlIOBigEndianPutUnaligned8(void *p, uint8_t v)
697 {
698     nlIOPutUnaligned8(p, v);
699 }
700
701 /**
702  * Perform an unaligned memory write of the target system
703  * byte ordered 16-bit value to the specified pointer address,
704  * perform byte reordering, as necessary, for the target system to
705  * put the value in big endian byte ordering.
706  *
707  * @param[in]  p      An unaligned pointer address to write
708  *                    the target system byte ordered 16-bit value to in big
709  *                    endian byte ordering.
710  *
711  * @param[in]  v      The 16-bit value to write.
712  *
713  */
714 static inline void     nlIOBigEndianPutUnaligned16(void *p, uint16_t v)
715 {
716     nlIOPutUnaligned16(p, nlByteOrderSwap16HostToBig(v));
717 }
718
719 /**
720  * Perform an unaligned memory write of the target system
721  * byte ordered 32-bit value to the specified pointer address,
722  * perform byte reordering, as necessary, for the target system to
723  * put the value in big endian byte ordering.
724  *
725  * @param[in]  p      An unaligned pointer address to write
726  *                    the target system byte ordered 32-bit value to in big
727  *                    endian byte ordering.
728  *
729  * @param[in]  v      The 32-bit value to write.
730  *
731  */
732 static inline void     nlIOBigEndianPutUnaligned32(void *p, uint32_t v)
733 {
734     nlIOPutUnaligned32(p, nlByteOrderSwap32HostToBig(v));
735 }
736
737 /**
738  * Perform an unaligned memory write of the target system
739  * byte ordered 64-bit value to the specified pointer address,
740  * perform byte reordering, as necessary, for the target system to
741  * put the value in big endian byte ordering.
742  *
743  * @param[in]  p      An unaligned pointer address to write
744  *                    the target system byte ordered 64-bit value to in big
745  *                    endian byte ordering.
746  *
747  * @param[in]  v      The 64-bit value to write.
748  *
749  */
750 static inline void     nlIOBigEndianPutUnaligned64(void *p, uint64_t v)
751 {
752     nlIOPutUnaligned64(p, nlByteOrderSwap64HostToBig(v));
753 }
754
755 /**
756  * Perform an unaligned memory read of the big endian
757  * byte ordered 8-bit value from the specified pointer address,
758  * perform byte reordering, as necessary, for the target system to put
759  * the value in target system byte ordering, and increment the pointer
760  * by 8-bits (1 byte).
761  *
762  * @param[inout]  p   A pointer to an unaligined pointer address, 
763  *                    to read the 8-bit big endian byte
764  *                    ordered value from and to then increment by 8-
765  *                    bits (1 byte).
766  *
767  * @return The 8-bit value at the specified pointer address.
768  */
769 static inline uint8_t  nlIOBigEndianReadUnaligned8(const void **p)
770 {
771     return nlIOReadUnaligned8(p);
772 }
773
774 /**
775  * Perform an unaligned memory read of the big endian
776  * byte ordered 16-bit value from the specified pointer address,
777  * perform byte reordering, as necessary, for the target system to put
778  * the value in target system byte ordering, and increment the pointer
779  * by 16-bits (2 bytes).
780  *
781  * @param[inout]  p   A pointer to an unaligined pointer address, 
782  *                    to read the 16-bit big endian byte
783  *                    ordered value from and to then increment by 16-
784  *                    bits (2 bytes).
785  *
786  * @return The 16-bit value at the specified pointer address.
787  */
788 static inline uint16_t nlIOBigEndianReadUnaligned16(const void **p)
789 {
790     return nlByteOrderSwap16BigToHost(nlIOReadUnaligned16(p));
791 }
792
793 /**
794  * Perform an unaligned memory read of the big endian
795  * byte ordered 32-bit value from the specified pointer address,
796  * perform byte reordering, as necessary, for the target system to put
797  * the value in target system byte ordering, and increment the pointer
798  * by 32-bits (4 bytes).
799  *
800  * @param[inout]  p   A pointer to an unaligined pointer address, 
801  *                    to read the 32-bit big endian byte
802  *                    ordered value from and to then increment by 32-
803  *                    bits (4 bytes).
804  *
805  * @return The 32-bit value at the specified pointer address.
806  */
807 static inline uint32_t nlIOBigEndianReadUnaligned32(const void **p)
808 {
809     return nlByteOrderSwap32BigToHost(nlIOReadUnaligned32(p));
810 }
811
812 /**
813  * Perform an unaligned memory read of the big endian
814  * byte ordered 64-bit value from the specified pointer address,
815  * perform byte reordering, as necessary, for the target system to put
816  * the value in target system byte ordering, and increment the pointer
817  * by 64-bits (8 bytes).
818  *
819  * @param[inout]  p   A pointer to an unaligined pointer address, 
820  *                    to read the 64-bit big endian byte
821  *                    ordered value from and to then increment by 64-
822  *                    bits (8 bytes).
823  *
824  * @return The 64-bit value at the specified pointer address.
825  */
826 static inline uint64_t nlIOBigEndianReadUnaligned64(const void **p)
827 {
828     return nlByteOrderSwap64BigToHost(nlIOReadUnaligned64(p));
829 }
830
831 /**
832  * Perform an unaligned memory write of the target system
833  * byte ordered 8-bit value to the specified pointer address,
834  * perform byte reordering, as necessary, for the target system to
835  * put the value in big endian byte ordering.
836  *
837  * @param[inout]  p   A pointer to an unaligined pointer address, 
838  *                    to write the target system byte
839  *                    ordered 8-bit value to in big endian byte
840  *                    ordering and to then increment by 8-bits (1
841  *                    byte).
842  *
843  * @param[in]  v      The 8-bit value to write.
844  *
845  */
846 static inline void     nlIOBigEndianWriteUnaligned8(void **p, uint8_t v)
847 {
848     nlIOWriteUnaligned8(p, v);
849 }
850
851 /**
852  * Perform an unaligned memory write of the target system
853  * byte ordered 16-bit value to the specified pointer address,
854  * perform byte reordering, as necessary, for the target system to
855  * put the value in big endian byte ordering.
856  *
857  * @param[inout]  p   A pointer to an unaligined pointer address, 
858  *                    to write the target system byte
859  *                    ordered 16-bit value to in big endian byte
860  *                    ordering and to then increment by 16-bits (2
861  *                    bytes).
862  *
863  * @param[in]  v      The 16-bit value to write.
864  *
865  */
866 static inline void     nlIOBigEndianWriteUnaligned16(void **p, uint16_t v)
867 {
868     nlIOWriteUnaligned16(p, nlByteOrderSwap16HostToBig(v));
869 }
870
871 /**
872  * Perform an unaligned memory write of the target system
873  * byte ordered 32-bit value to the specified pointer address,
874  * perform byte reordering, as necessary, for the target system to
875  * put the value in big endian byte ordering.
876  *
877  * @param[inout]  p   A pointer to an unaligined pointer address, 
878  *                    to write the target system byte
879  *                    ordered 32-bit value to in big endian byte
880  *                    ordering and to then increment by 32-bits (4
881  *                    bytes).
882  *
883  * @param[in]  v      The 32-bit value to write.
884  *
885  */
886 static inline void     nlIOBigEndianWriteUnaligned32(void **p, uint32_t v)
887 {
888     nlIOWriteUnaligned32(p, nlByteOrderSwap32HostToBig(v));
889 }
890
891 /**
892  * Perform an unaligned memory write of the target system
893  * byte ordered 64-bit value to the specified pointer address,
894  * perform byte reordering, as necessary, for the target system to
895  * put the value in big endian byte ordering.
896  *
897  * @param[inout]  p   A pointer to an unaligined pointer address, 
898  *                    to write the target system byte
899  *                    ordered 64-bit value to in big endian byte
900  *                    ordering and to then increment by 64-bits (8
901  *                    bytes).
902  *
903  * @param[in]  v      The 64-bit value to write.
904  *
905  */
906 static inline void     nlIOBigEndianWriteUnaligned64(void **p, uint64_t v)
907 {
908     nlIOWriteUnaligned64(p, nlByteOrderSwap64HostToBig(v));
909 }
910
911 #ifdef __cplusplus
912 }
913 #endif
914
915 #endif /* NLIO_BYTEORDER_BIG_H */