2 * Copyright 2013-2016 Nest Labs Inc. All Rights Reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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.
25 #ifndef NLIO_BYTEORDER_BIG_H
26 #define NLIO_BYTEORDER_BIG_H
28 #include <nlio-base.h>
29 #include <nlbyteorder.h>
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.
41 * @param[in] p A pointer address, potentially unaligned, to read
42 * the 8-bit big endian byte ordered value from.
44 * @return The 8-bit value at the specified pointer address.
46 static inline uint8_t nlIOBigEndianGet8(const void *p)
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.
57 * @param[in] p A pointer address, potentially unaligned, to read
58 * the 16-bit big endian byte ordered value from.
60 * @return The 16-bit value at the specified pointer address.
62 static inline uint16_t nlIOBigEndianGet16(const void *p)
64 return nlByteOrderSwap16BigToHost(nlIOGet16(p));
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.
73 * @param[in] p A pointer address, potentially unaligned, to read
74 * the 32-bit big endian byte ordered value from.
76 * @return The 32-bit value at the specified pointer address.
78 static inline uint32_t nlIOBigEndianGet32(const void *p)
80 return nlByteOrderSwap32BigToHost(nlIOGet32(p));
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.
89 * @param[in] p A pointer address, potentially unaligned, to read
90 * the 64-bit big endian byte ordered value from.
92 * @return The 64-bit value at the specified pointer address.
94 static inline uint64_t nlIOBigEndianGet64(const void *p)
96 return nlByteOrderSwap64BigToHost(nlIOGet64(p));
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.
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.
109 * @param[in] v The 8-bit value to write.
112 static inline void nlIOBigEndianPut8(void *p, uint8_t v)
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.
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.
127 * @param[in] v The 16-bit value to write.
130 static inline void nlIOBigEndianPut16(void *p, uint16_t v)
132 nlIOPut16(p, nlByteOrderSwap16HostToBig(v));
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.
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.
145 * @param[in] v The 32-bit value to write.
148 static inline void nlIOBigEndianPut32(void *p, uint32_t v)
150 nlIOPut32(p, nlByteOrderSwap32HostToBig(v));
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.
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.
163 * @param[in] v The 64-bit value to write.
166 static inline void nlIOBigEndianPut64(void *p, uint64_t v)
168 nlIOPut64(p, nlByteOrderSwap64HostToBig(v));
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).
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-
183 * @return The 8-bit value at the specified pointer address.
185 static inline uint8_t nlIOBigEndianRead8(const void **p)
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).
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-
202 * @return The 16-bit value at the specified pointer address.
204 static inline uint16_t nlIOBigEndianRead16(const void **p)
206 return nlByteOrderSwap16BigToHost(nlIORead16(p));
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).
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-
221 * @return The 32-bit value at the specified pointer address.
223 static inline uint32_t nlIOBigEndianRead32(const void **p)
225 return nlByteOrderSwap32BigToHost(nlIORead32(p));
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).
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-
240 * @return The 64-bit value at the specified pointer address.
242 static inline uint64_t nlIOBigEndianRead64(const void **p)
244 return nlByteOrderSwap64BigToHost(nlIORead64(p));
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.
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
259 * @param[in] v The 8-bit value to write.
262 static inline void nlIOBigEndianWrite8(void **p, uint8_t v)
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.
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
279 * @param[in] v The 16-bit value to write.
282 static inline void nlIOBigEndianWrite16(void **p, uint16_t v)
284 nlIOWrite16(p, nlByteOrderSwap16HostToBig(v));
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.
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
299 * @param[in] v The 32-bit value to write.
302 static inline void nlIOBigEndianWrite32(void **p, uint32_t v)
304 nlIOWrite32(p, nlByteOrderSwap32HostToBig(v));
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.
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
319 * @param[in] v The 64-bit value to write.
322 static inline void nlIOBigEndianWrite64(void **p, uint64_t v)
324 nlIOWrite64(p, nlByteOrderSwap64HostToBig(v));
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.
333 * @param[in] p An aligned pointer address to read
334 * the 8-bit big endian byte ordered value from.
336 * @return The 8-bit value at the specified pointer address.
338 static inline uint8_t nlIOBigEndianGetAligned8(const void *p)
340 return nlIOGetAligned8(p);
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.
349 * @param[in] p An aligned pointer address to read
350 * the 16-bit big endian byte ordered value from.
352 * @return The 16-bit value at the specified pointer address.
354 static inline uint16_t nlIOBigEndianGetAligned16(const void *p)
356 return nlByteOrderSwap16BigToHost(nlIOGetAligned16(p));
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.
365 * @param[in] p An aligned pointer address to read
366 * the 32-bit big endian byte ordered value from.
368 * @return The 32-bit value at the specified pointer address.
370 static inline uint32_t nlIOBigEndianGetAligned32(const void *p)
372 return nlByteOrderSwap32BigToHost(nlIOGetAligned32(p));
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.
381 * @param[in] p An aligned pointer address to read
382 * the 64-bit big endian byte ordered value from.
384 * @return The 64-bit value at the specified pointer address.
386 static inline uint64_t nlIOBigEndianGetAligned64(const void *p)
388 return nlByteOrderSwap64BigToHost(nlIOGetAligned64(p));
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.
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.
401 * @param[in] v The 8-bit value to write.
404 static inline void nlIOBigEndianPutAligned8(void *p, uint8_t v)
406 nlIOPutAligned8(p, v);
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.
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.
419 * @param[in] v The 16-bit value to write.
422 static inline void nlIOBigEndianPutAligned16(void *p, uint16_t v)
424 nlIOPutAligned16(p, nlByteOrderSwap16HostToBig(v));
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.
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.
437 * @param[in] v The 32-bit value to write.
440 static inline void nlIOBigEndianPutAligned32(void *p, uint32_t v)
442 nlIOPutAligned32(p, nlByteOrderSwap32HostToBig(v));
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.
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.
455 * @param[in] v The 64-bit value to write.
458 static inline void nlIOBigEndianPutAligned64(void *p, uint64_t v)
460 nlIOPutAligned64(p, nlByteOrderSwap64HostToBig(v));
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).
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-
475 * @return The 8-bit value at the specified pointer address.
477 static inline uint8_t nlIOBigEndianReadAligned8(const void **p)
479 return nlIOReadAligned8(p);
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).
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-
494 * @return The 16-bit value at the specified pointer address.
496 static inline uint16_t nlIOBigEndianReadAligned16(const void **p)
498 return nlByteOrderSwap16BigToHost(nlIOReadAligned16(p));
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).
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-
513 * @return The 32-bit value at the specified pointer address.
515 static inline uint32_t nlIOBigEndianReadAligned32(const void **p)
517 return nlByteOrderSwap32BigToHost(nlIOReadAligned32(p));
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).
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-
532 * @return The 64-bit value at the specified pointer address.
534 static inline uint64_t nlIOBigEndianReadAligned64(const void **p)
536 return nlByteOrderSwap64BigToHost(nlIOReadAligned64(p));
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.
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
551 * @param[in] v The 8-bit value to write.
554 static inline void nlIOBigEndianWriteAligned8(void **p, uint8_t v)
556 nlIOWriteAligned8(p, v);
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.
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
571 * @param[in] v The 16-bit value to write.
574 static inline void nlIOBigEndianWriteAligned16(void **p, uint16_t v)
576 nlIOWriteAligned16(p, nlByteOrderSwap16HostToBig(v));
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.
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
591 * @param[in] v The 32-bit value to write.
594 static inline void nlIOBigEndianWriteAligned32(void **p, uint32_t v)
596 nlIOWriteAligned32(p, nlByteOrderSwap32HostToBig(v));
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.
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
611 * @param[in] v The 64-bit value to write.
614 static inline void nlIOBigEndianWriteAligned64(void **p, uint64_t v)
616 nlIOWriteAligned64(p, nlByteOrderSwap64HostToBig(v));
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.
625 * @param[in] p An unaligned pointer address to read
626 * the 8-bit big endian byte ordered value from.
628 * @return The 8-bit value at the specified pointer address.
630 static inline uint8_t nlIOBigEndianGetUnaligned8(const void *p)
632 return nlIOGetUnaligned8(p);
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.
641 * @param[in] p An unaligned pointer address to read
642 * the 16-bit big endian byte ordered value from.
644 * @return The 16-bit value at the specified pointer address.
646 static inline uint16_t nlIOBigEndianGetUnaligned16(const void *p)
648 return nlByteOrderSwap16BigToHost(nlIOGetUnaligned16(p));
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.
657 * @param[in] p An unaligned pointer address to read
658 * the 32-bit big endian byte ordered value from.
660 * @return The 32-bit value at the specified pointer address.
662 static inline uint32_t nlIOBigEndianGetUnaligned32(const void *p)
664 return nlByteOrderSwap32BigToHost(nlIOGetUnaligned32(p));
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.
673 * @param[in] p An unaligned pointer address to read
674 * the 64-bit big endian byte ordered value from.
676 * @return The 64-bit value at the specified pointer address.
678 static inline uint64_t nlIOBigEndianGetUnaligned64(const void *p)
680 return nlByteOrderSwap64BigToHost(nlIOGetUnaligned64(p));
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.
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.
693 * @param[in] v The 8-bit value to write.
696 static inline void nlIOBigEndianPutUnaligned8(void *p, uint8_t v)
698 nlIOPutUnaligned8(p, v);
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.
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.
711 * @param[in] v The 16-bit value to write.
714 static inline void nlIOBigEndianPutUnaligned16(void *p, uint16_t v)
716 nlIOPutUnaligned16(p, nlByteOrderSwap16HostToBig(v));
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.
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.
729 * @param[in] v The 32-bit value to write.
732 static inline void nlIOBigEndianPutUnaligned32(void *p, uint32_t v)
734 nlIOPutUnaligned32(p, nlByteOrderSwap32HostToBig(v));
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.
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.
747 * @param[in] v The 64-bit value to write.
750 static inline void nlIOBigEndianPutUnaligned64(void *p, uint64_t v)
752 nlIOPutUnaligned64(p, nlByteOrderSwap64HostToBig(v));
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).
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-
767 * @return The 8-bit value at the specified pointer address.
769 static inline uint8_t nlIOBigEndianReadUnaligned8(const void **p)
771 return nlIOReadUnaligned8(p);
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).
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-
786 * @return The 16-bit value at the specified pointer address.
788 static inline uint16_t nlIOBigEndianReadUnaligned16(const void **p)
790 return nlByteOrderSwap16BigToHost(nlIOReadUnaligned16(p));
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).
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-
805 * @return The 32-bit value at the specified pointer address.
807 static inline uint32_t nlIOBigEndianReadUnaligned32(const void **p)
809 return nlByteOrderSwap32BigToHost(nlIOReadUnaligned32(p));
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).
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-
824 * @return The 64-bit value at the specified pointer address.
826 static inline uint64_t nlIOBigEndianReadUnaligned64(const void **p)
828 return nlByteOrderSwap64BigToHost(nlIOReadUnaligned64(p));
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.
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
843 * @param[in] v The 8-bit value to write.
846 static inline void nlIOBigEndianWriteUnaligned8(void **p, uint8_t v)
848 nlIOWriteUnaligned8(p, v);
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.
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
863 * @param[in] v The 16-bit value to write.
866 static inline void nlIOBigEndianWriteUnaligned16(void **p, uint16_t v)
868 nlIOWriteUnaligned16(p, nlByteOrderSwap16HostToBig(v));
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.
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
883 * @param[in] v The 32-bit value to write.
886 static inline void nlIOBigEndianWriteUnaligned32(void **p, uint32_t v)
888 nlIOWriteUnaligned32(p, nlByteOrderSwap32HostToBig(v));
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.
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
903 * @param[in] v The 64-bit value to write.
906 static inline void nlIOBigEndianWriteUnaligned64(void **p, uint64_t v)
908 nlIOWriteUnaligned64(p, nlByteOrderSwap64HostToBig(v));
915 #endif /* NLIO_BYTEORDER_BIG_H */