Lely core libraries  2.2.5
endian.h
Go to the documentation of this file.
1 
22 #ifndef LELY_UTIL_ENDIAN_H_
23 #define LELY_UTIL_ENDIAN_H_
24 
25 #include <lely/util/bits.h>
26 #include <lely/util/float.h>
27 
28 #include <string.h>
29 
30 #ifndef LELY_UTIL_ENDIAN_INLINE
31 #define LELY_UTIL_ENDIAN_INLINE static inline
32 #endif
33 
34 #ifndef LELY_BIG_ENDIAN
35 #if defined(__BIG_ENDIAN__) || defined(__big_endian__) \
36  || (__GNUC__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) \
37  || defined(__ARMEB__) || defined(__AARCH64EB__) \
38  || defined(__THUMBEB__)
39 #define LELY_BIG_ENDIAN 1
41 #endif
42 #endif
43 
44 #if LELY_BIG_ENDIAN
45 #undef LELY_LITTLE_ENDIAN
46 #endif
47 
48 #ifndef LELY_LITTLE_ENDIAN
49 #if defined(__LITTLE_ENDIAN__) || defined(__little_endian__) \
50  || (__GNUC__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) \
51  || defined(__i386__) || defined(_M_IX86) \
52  || defined(__x86_64__) || defined(_M_AMD64) \
53  || defined(__ARMEL__) || defined(__AARCH64EL__) \
54  || defined(__THUMBEL__)
55 #define LELY_LITTLE_ENDIAN 1
57 #endif
58 #endif
59 
60 #if LELY_LITTLE_ENDIAN
61 #undef LELY_BIG_ENDIAN
62 #endif
63 
64 #if !LELY_BIG_ENDIAN && !LELY_LITTLE_ENDIAN
65 #error Unable to determine byte order or byte order is not supported.
66 #endif
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
72 #ifndef htobe16
73 LELY_UTIL_ENDIAN_INLINE uint_least16_t htobe16(uint_least16_t x);
75 #endif
76 
77 #ifndef betoh16
78 LELY_UTIL_ENDIAN_INLINE uint_least16_t betoh16(uint_least16_t x);
80 #endif
81 
82 #ifndef htole16
83 LELY_UTIL_ENDIAN_INLINE uint_least16_t htole16(uint_least16_t x);
85 #endif
86 
87 #ifndef letoh16
88 LELY_UTIL_ENDIAN_INLINE uint_least16_t letoh16(uint_least16_t x);
90 #endif
91 
92 #ifndef htobe32
93 LELY_UTIL_ENDIAN_INLINE uint_least32_t htobe32(uint_least32_t x);
95 #endif
96 
97 #ifndef betoh32
98 LELY_UTIL_ENDIAN_INLINE uint_least32_t betoh32(uint_least32_t x);
100 #endif
101 
102 #ifndef htole32
103 LELY_UTIL_ENDIAN_INLINE uint_least32_t htole32(uint_least32_t x);
105 #endif
106 
107 #ifndef letoh32
108 LELY_UTIL_ENDIAN_INLINE uint_least32_t letoh32(uint_least32_t x);
110 #endif
111 
112 #ifndef htobe64
113 LELY_UTIL_ENDIAN_INLINE uint_least64_t htobe64(uint_least64_t x);
115 #endif
116 
117 #ifndef betoh64
118 LELY_UTIL_ENDIAN_INLINE uint_least64_t betoh64(uint_least64_t x);
120 #endif
121 
122 #ifndef htole64
123 LELY_UTIL_ENDIAN_INLINE uint_least64_t htole64(uint_least64_t x);
125 #endif
126 
127 #ifndef letoh64
128 LELY_UTIL_ENDIAN_INLINE uint_least64_t letoh64(uint_least64_t x);
130 #endif
131 
133 LELY_UTIL_ENDIAN_INLINE void stbe_i16(uint_least8_t dst[2], int_least16_t x);
134 
136 LELY_UTIL_ENDIAN_INLINE int_least16_t ldbe_i16(const uint_least8_t src[2]);
137 
139 LELY_UTIL_ENDIAN_INLINE void stbe_u16(uint_least8_t dst[2], uint_least16_t x);
140 
142 LELY_UTIL_ENDIAN_INLINE uint_least16_t ldbe_u16(const uint_least8_t src[2]);
143 
145 LELY_UTIL_ENDIAN_INLINE void stle_i16(uint_least8_t dst[2], int_least16_t x);
146 
148 LELY_UTIL_ENDIAN_INLINE int_least16_t ldle_i16(const uint_least8_t src[2]);
149 
151 LELY_UTIL_ENDIAN_INLINE void stle_u16(uint_least8_t dst[2], uint_least16_t x);
152 
154 LELY_UTIL_ENDIAN_INLINE uint_least16_t ldle_u16(const uint_least8_t src[2]);
155 
157 LELY_UTIL_ENDIAN_INLINE void stbe_i32(uint_least8_t dst[4], int_least32_t x);
158 
160 LELY_UTIL_ENDIAN_INLINE int_least32_t ldbe_i32(const uint_least8_t src[4]);
161 
163 LELY_UTIL_ENDIAN_INLINE void stbe_u32(uint_least8_t dst[4], uint_least32_t x);
164 
166 LELY_UTIL_ENDIAN_INLINE uint_least32_t ldbe_u32(const uint_least8_t src[4]);
167 
169 LELY_UTIL_ENDIAN_INLINE void stle_i32(uint_least8_t dst[4], int_least32_t x);
170 
172 LELY_UTIL_ENDIAN_INLINE int_least32_t ldle_i32(const uint_least8_t src[4]);
173 
175 LELY_UTIL_ENDIAN_INLINE void stle_u32(uint_least8_t dst[4], uint_least32_t x);
176 
178 LELY_UTIL_ENDIAN_INLINE uint_least32_t ldle_u32(const uint_least8_t src[4]);
179 
181 LELY_UTIL_ENDIAN_INLINE void stbe_i64(uint_least8_t dst[8], int_least64_t x);
182 
184 LELY_UTIL_ENDIAN_INLINE int_least64_t ldbe_i64(const uint_least8_t src[8]);
185 
187 LELY_UTIL_ENDIAN_INLINE void stbe_u64(uint_least8_t dst[8], uint_least64_t x);
188 
190 LELY_UTIL_ENDIAN_INLINE uint_least64_t ldbe_u64(const uint_least8_t src[8]);
191 
193 LELY_UTIL_ENDIAN_INLINE void stle_i64(uint_least8_t dst[8], int_least64_t x);
194 
196 LELY_UTIL_ENDIAN_INLINE int_least64_t ldle_i64(const uint_least8_t src[8]);
197 
199 LELY_UTIL_ENDIAN_INLINE void stle_u64(uint_least8_t dst[8], uint_least64_t x);
200 
202 LELY_UTIL_ENDIAN_INLINE uint_least64_t ldle_u64(const uint_least8_t src[8]);
203 
204 #ifdef LELY_FLT16_TYPE
205 
210 LELY_UTIL_ENDIAN_INLINE void stbe_flt16(uint_least8_t dst[2], flt16_t x);
211 
216 LELY_UTIL_ENDIAN_INLINE flt16_t ldbe_flt16(const uint_least8_t src[2]);
217 
222 LELY_UTIL_ENDIAN_INLINE void stle_flt16(uint_least8_t dst[2], flt16_t x);
223 
228 LELY_UTIL_ENDIAN_INLINE flt16_t ldle_flt16(const uint_least8_t src[2]);
229 
230 #endif // LELY_FLT16_TYPE
231 
232 #ifdef LELY_FLT32_TYPE
233 
238 LELY_UTIL_ENDIAN_INLINE void stbe_flt32(uint_least8_t dst[4], flt32_t x);
239 
244 LELY_UTIL_ENDIAN_INLINE flt32_t ldbe_flt32(const uint_least8_t src[4]);
245 
250 LELY_UTIL_ENDIAN_INLINE void stle_flt32(uint_least8_t dst[4], flt32_t x);
251 
256 LELY_UTIL_ENDIAN_INLINE flt32_t ldle_flt32(const uint_least8_t src[4]);
257 
258 #endif // LELY_FLT32_TYPE
259 
260 #ifdef LELY_FLT64_TYPE
261 
266 LELY_UTIL_ENDIAN_INLINE void stbe_flt64(uint_least8_t dst[8], flt64_t x);
267 
272 LELY_UTIL_ENDIAN_INLINE flt64_t ldbe_flt64(const uint_least8_t src[8]);
273 
278 LELY_UTIL_ENDIAN_INLINE void stle_flt64(uint_least8_t dst[8], flt64_t x);
279 
284 LELY_UTIL_ENDIAN_INLINE flt64_t ldle_flt64(const uint_least8_t src[8]);
285 
286 #endif // LELY_FLT64_TYPE
287 
300 void bcpybe(uint_least8_t *dst, int dstbit, const uint_least8_t *src,
301  int srcbit, size_t n);
302 
315 void bcpyle(uint_least8_t *dst, int dstbit, const uint_least8_t *src,
316  int srcbit, size_t n);
317 
318 #ifndef htobe16
319 inline uint_least16_t
320 htobe16(uint_least16_t x)
321 {
322  x &= UINT16_C(0xffff);
323 #if LELY_BIG_ENDIAN
324  return x;
325 #elif LELY_LITTLE_ENDIAN
326  return bswap16(x);
327 #endif
328 }
329 #endif
330 
331 #ifndef betoh16
332 inline uint_least16_t
333 betoh16(uint_least16_t x)
334 {
335  return htobe16(x);
336 }
337 #endif
338 
339 #ifndef htole16
340 inline uint_least16_t
341 htole16(uint_least16_t x)
342 {
343  x &= UINT16_C(0xffff);
344 #if LELY_BIG_ENDIAN
345  return bswap16(x);
346 #elif LELY_LITTLE_ENDIAN
347  return x;
348 #endif
349 }
350 #endif
351 
352 #ifndef letoh16
353 inline uint_least16_t
354 letoh16(uint_least16_t x)
355 {
356  return htole16(x);
357 }
358 #endif
359 
360 #ifndef htobe32
361 inline uint_least32_t
362 htobe32(uint_least32_t x)
363 {
364  x &= UINT32_C(0xffffffff);
365 #if LELY_BIG_ENDIAN
366  return x;
367 #elif LELY_LITTLE_ENDIAN
368  return bswap32(x);
369 #endif
370 }
371 #endif
372 
373 #ifndef betoh32
374 inline uint_least32_t
375 betoh32(uint_least32_t x)
376 {
377  return htobe32(x);
378 }
379 #endif
380 
381 #ifndef htole32
382 inline uint_least32_t
383 htole32(uint_least32_t x)
384 {
385  x &= UINT32_C(0xffffffff);
386 #if LELY_BIG_ENDIAN
387  return bswap32(x);
388 #elif LELY_LITTLE_ENDIAN
389  return x;
390 #endif
391 }
392 #endif
393 
394 #ifndef letoh32
395 inline uint_least32_t
396 letoh32(uint_least32_t x)
397 {
398  return htole32(x);
399 }
400 #endif
401 
402 #ifndef htobe64
403 inline uint_least64_t
404 htobe64(uint_least64_t x)
405 {
406  x &= UINT64_C(0xffffffffffffffff);
407 #if LELY_BIG_ENDIAN
408  return x;
409 #elif LELY_LITTLE_ENDIAN
410  return bswap64(x);
411 #endif
412 }
413 #endif
414 
415 #ifndef betoh64
416 inline uint_least64_t
417 betoh64(uint_least64_t x)
418 {
419  return htobe64(x);
420 }
421 #endif
422 
423 #ifndef htole64
424 inline uint_least64_t
425 htole64(uint_least64_t x)
426 {
427  x &= UINT64_C(0xffffffffffffffff);
428 #if LELY_BIG_ENDIAN
429  return bswap64(x);
430 #elif LELY_LITTLE_ENDIAN
431  return x;
432 #endif
433 }
434 #endif
435 
436 #ifndef letoh64
437 inline uint_least64_t
438 letoh64(uint_least64_t x)
439 {
440  return htole64(x);
441 }
442 #endif
443 
444 inline void
445 stbe_i16(uint_least8_t dst[2], int_least16_t x)
446 {
447  stbe_u16(dst, x);
448 }
449 
450 inline int_least16_t
451 ldbe_i16(const uint_least8_t src[2])
452 {
453  return ldbe_u16(src);
454 }
455 
456 inline void
457 stbe_u16(uint_least8_t dst[2], uint_least16_t x)
458 {
459 #if CHAR_BIT == 8
460  x = htobe16(x);
461  memcpy(dst, &x, sizeof(x));
462 #else
463  dst[0] = (x >> 8) & 0xff;
464  dst[1] = x & 0xff;
465 #endif
466 }
467 
468 inline uint_least16_t
469 ldbe_u16(const uint_least8_t src[2])
470 {
471 #if CHAR_BIT == 8
472  uint_least16_t x = 0;
473  memcpy(&x, src, sizeof(x));
474  return betoh16(x);
475 #else
476  return ((uint_least16_t)(src[0] & 0xff) << 8)
477  | ((uint_least16_t)(src[1] & 0xff));
478 #endif
479 }
480 
481 inline void
482 stle_i16(uint_least8_t dst[2], int_least16_t x)
483 {
484  stle_u16(dst, x);
485 }
486 
487 inline int_least16_t
488 ldle_i16(const uint_least8_t src[2])
489 {
490  return ldle_u16(src);
491 }
492 
493 inline void
494 stle_u16(uint_least8_t dst[2], uint_least16_t x)
495 {
496 #if CHAR_BIT == 8
497  x = htole16(x);
498  memcpy(dst, &x, sizeof(x));
499 #else
500  dst[0] = x & 0xff;
501  dst[1] = (x >> 8) & 0xff;
502 #endif
503 }
504 
505 inline uint_least16_t
506 ldle_u16(const uint_least8_t src[2])
507 {
508 #if CHAR_BIT == 8
509  uint_least16_t x = 0;
510  memcpy(&x, src, sizeof(x));
511  return letoh16(x);
512 #else
513  return (uint_least16_t)(src[0] & 0xff)
514  | ((uint_least16_t)(src[1] & 0xff) << 8);
515 #endif
516 }
517 
518 inline void
519 stbe_i32(uint_least8_t dst[4], int_least32_t x)
520 {
521  stbe_u32(dst, x);
522 }
523 
524 inline int_least32_t
525 ldbe_i32(const uint_least8_t src[4])
526 {
527  return ldbe_u32(src);
528 }
529 
530 inline void
531 stbe_u32(uint_least8_t dst[4], uint_least32_t x)
532 {
533 #if CHAR_BIT == 8
534  x = htobe32(x);
535  memcpy(dst, &x, sizeof(x));
536 #else
537  dst[0] = (x >> 24) & 0xff;
538  dst[1] = (x >> 16) & 0xff;
539  dst[2] = (x >> 8) & 0xff;
540  dst[3] = x & 0xff;
541 #endif
542 }
543 
544 inline uint_least32_t
545 ldbe_u32(const uint_least8_t src[4])
546 {
547 #if CHAR_BIT == 8
548  uint_least32_t x = 0;
549  memcpy(&x, src, sizeof(x));
550  return betoh32(x);
551 #else
552  return ((uint_least32_t)(src[0] & 0xff) << 24)
553  | ((uint_least32_t)(src[1] & 0xff) << 16)
554  | ((uint_least32_t)(src[2] & 0xff) << 8)
555  | ((uint_least32_t)(src[3] & 0xff));
556 #endif
557 }
558 
559 inline void
560 stle_i32(uint_least8_t dst[4], int_least32_t x)
561 {
562  stle_u32(dst, x);
563 }
564 
565 inline int_least32_t
566 ldle_i32(const uint_least8_t src[4])
567 {
568  return ldle_u32(src);
569 }
570 
571 inline void
572 stle_u32(uint_least8_t dst[4], uint_least32_t x)
573 {
574 #if CHAR_BIT == 8
575  x = htole32(x);
576  memcpy(dst, &x, sizeof(x));
577 #else
578  dst[0] = x & 0xff;
579  dst[1] = (x >> 8) & 0xff;
580  dst[2] = (x >> 16) & 0xff;
581  dst[3] = (x >> 24) & 0xff;
582 #endif
583 }
584 
585 inline uint_least32_t
586 ldle_u32(const uint_least8_t src[4])
587 {
588 #if CHAR_BIT == 8
589  uint_least32_t x = 0;
590  memcpy(&x, src, sizeof(x));
591  return letoh32(x);
592 #else
593  return (uint_least32_t)(src[0] & 0xff)
594  | ((uint_least32_t)(src[1] & 0xff) << 8)
595  | ((uint_least32_t)(src[2] & 0xff) << 16)
596  | ((uint_least32_t)(src[3] & 0xff) << 24);
597 #endif
598 }
599 
600 inline void
601 stbe_i64(uint_least8_t dst[8], int_least64_t x)
602 {
603  stbe_u64(dst, x);
604 }
605 
606 inline int_least64_t
607 ldbe_i64(const uint_least8_t src[8])
608 {
609  return ldbe_u64(src);
610 }
611 
612 inline void
613 stbe_u64(uint_least8_t dst[8], uint_least64_t x)
614 {
615 #if CHAR_BIT == 8
616  x = htobe64(x);
617  memcpy(dst, &x, sizeof(x));
618 #else
619  dst[0] = (x >> 56) & 0xff;
620  dst[1] = (x >> 48) & 0xff;
621  dst[2] = (x >> 40) & 0xff;
622  dst[3] = (x >> 32) & 0xff;
623  dst[4] = (x >> 24) & 0xff;
624  dst[5] = (x >> 16) & 0xff;
625  dst[6] = (x >> 8) & 0xff;
626  dst[7] = x & 0xff;
627 #endif
628 }
629 
630 inline uint_least64_t
631 ldbe_u64(const uint_least8_t src[8])
632 {
633 #if CHAR_BIT == 8
634  uint_least64_t x = 0;
635  memcpy(&x, src, sizeof(x));
636  return betoh64(x);
637 #else
638  return ((uint_least64_t)(src[0] & 0xff) << 56)
639  | ((uint_least64_t)(src[1] & 0xff) << 48)
640  | ((uint_least64_t)(src[2] & 0xff) << 40)
641  | ((uint_least64_t)(src[3] & 0xff) << 32)
642  | ((uint_least64_t)(src[4] & 0xff) << 24)
643  | ((uint_least64_t)(src[5] & 0xff) << 16)
644  | ((uint_least64_t)(src[6] & 0xff) << 8)
645  | ((uint_least64_t)(src[7] & 0xff));
646 #endif
647 }
648 
649 inline void
650 stle_i64(uint_least8_t dst[8], int_least64_t x)
651 {
652  stle_u64(dst, x);
653 }
654 
655 inline int_least64_t
656 ldle_i64(const uint_least8_t src[8])
657 {
658  return ldle_u64(src);
659 }
660 
661 inline void
662 stle_u64(uint_least8_t dst[8], uint_least64_t x)
663 {
664 #if CHAR_BIT == 8
665  x = htole64(x);
666  memcpy(dst, &x, sizeof(x));
667 #else
668  dst[0] = x & 0xff;
669  dst[1] = (x >> 8) & 0xff;
670  dst[2] = (x >> 16) & 0xff;
671  dst[3] = (x >> 24) & 0xff;
672  dst[4] = (x >> 32) & 0xff;
673  dst[5] = (x >> 40) & 0xff;
674  dst[6] = (x >> 48) & 0xff;
675  dst[7] = (x >> 56) & 0xff;
676 #endif
677 }
678 
679 inline uint_least64_t
680 ldle_u64(const uint_least8_t src[8])
681 {
682 #if CHAR_BIT == 8
683  uint_least64_t x = 0;
684  memcpy(&x, src, sizeof(x));
685  return letoh64(x);
686 #else
687  return (uint_least64_t)(src[0] & 0xff)
688  | ((uint_least64_t)(src[1] & 0xff) << 8)
689  | ((uint_least64_t)(src[2] & 0xff) << 16)
690  | ((uint_least64_t)(src[3] & 0xff) << 24)
691  | ((uint_least64_t)(src[4] & 0xff) << 32)
692  | ((uint_least64_t)(src[5] & 0xff) << 40)
693  | ((uint_least64_t)(src[6] & 0xff) << 48)
694  | ((uint_least64_t)(src[7] & 0xff) << 56);
695 #endif
696 }
697 
698 #ifdef LELY_FLT16_TYPE
699 
700 inline void
701 stbe_flt16(uint_least8_t dst[2], flt16_t x)
702 {
703  uint_least16_t tmp = 0;
704  memcpy(&tmp, &x, sizeof(x));
705  stbe_u16(dst, tmp);
706 }
707 
708 inline flt16_t
709 ldbe_flt16(const uint_least8_t src[2])
710 {
711  flt16_t x = 0;
712  uint_least16_t tmp = ldbe_u16(src);
713  memcpy(&x, &tmp, sizeof(x));
714  return x;
715 }
716 
717 inline void
718 stle_flt16(uint_least8_t dst[2], flt16_t x)
719 {
720  uint_least16_t tmp = 0;
721  memcpy(&tmp, &x, sizeof(x));
722  stle_u16(dst, tmp);
723 }
724 
725 inline flt16_t
726 ldle_flt16(const uint_least8_t src[2])
727 {
728  flt16_t x = 0;
729  uint_least16_t tmp = ldle_u16(src);
730  memcpy(&x, &tmp, sizeof(x));
731  return x;
732 }
733 
734 #endif // LELY_FLT16_TYPE
735 
736 #ifdef LELY_FLT32_TYPE
737 
738 inline void
739 stbe_flt32(uint_least8_t dst[4], flt32_t x)
740 {
741  uint_least32_t tmp = 0;
742  memcpy(&tmp, &x, sizeof(x));
743  stbe_u32(dst, tmp);
744 }
745 
746 inline flt32_t
747 ldbe_flt32(const uint_least8_t src[4])
748 {
749  flt32_t x = 0;
750  uint_least32_t tmp = ldbe_u32(src);
751  memcpy(&x, &tmp, sizeof(x));
752  return x;
753 }
754 
755 inline void
756 stle_flt32(uint_least8_t dst[4], flt32_t x)
757 {
758  uint_least32_t tmp = 0;
759  memcpy(&tmp, &x, sizeof(x));
760  stle_u32(dst, tmp);
761 }
762 
763 inline flt32_t
764 ldle_flt32(const uint_least8_t src[4])
765 {
766  flt32_t x = 0;
767  uint_least32_t tmp = ldle_u32(src);
768  memcpy(&x, &tmp, sizeof(x));
769  return x;
770 }
771 
772 #endif // LELY_FLT32_TYPE
773 
774 #ifdef LELY_FLT64_TYPE
775 
776 inline void
777 stbe_flt64(uint_least8_t dst[8], flt64_t x)
778 {
779  uint_least64_t tmp = 0;
780  memcpy(&tmp, &x, sizeof(x));
781  stbe_u64(dst, tmp);
782 }
783 
784 inline flt64_t
785 ldbe_flt64(const uint_least8_t src[8])
786 {
787  flt64_t x = 0;
788  uint_least64_t tmp = ldbe_u64(src);
789  memcpy(&x, &tmp, sizeof(x));
790  return x;
791 }
792 
793 inline void
794 stle_flt64(uint_least8_t dst[8], flt64_t x)
795 {
796  uint_least64_t tmp = 0;
797  memcpy(&tmp, &x, sizeof(x));
798  stle_u64(dst, tmp);
799 }
800 
801 inline flt64_t
802 ldle_flt64(const uint_least8_t src[8])
803 {
804  flt64_t x = 0;
805  uint_least64_t tmp = ldle_u64(src);
806  memcpy(&x, &tmp, sizeof(x));
807  return x;
808 }
809 
810 #endif // LELY_FLT64_TYPE
811 
812 #ifdef __cplusplus
813 }
814 #endif
815 
816 #endif // !LELY_UTIL_ENDIAN_H_
uint_least16_t htole16(uint_least16_t x)
Converts a 16-bit unsigned integer from host to little-endian byte order.
Definition: endian.h:341
void stbe_i16(uint_least8_t dst[2], int_least16_t x)
Stores a 16-bit signed integer in big-endian byte order.
Definition: endian.h:445
void stbe_u16(uint_least8_t dst[2], uint_least16_t x)
Stores a 16-bit unsigned integer in big-endian byte order.
Definition: endian.h:457
uint_least32_t betoh32(uint_least32_t x)
Converts a 32-bit unsigned integer from big-endian to host byte order.
Definition: endian.h:375
This header file is part of the C11 and POSIX compatibility library; it includes <string.h> and defines any missing functionality.
uint_least32_t letoh32(uint_least32_t x)
Converts a 32-bit unsigned integer from little-endian to host byte order.
Definition: endian.h:396
uint_least64_t bswap64(uint_least64_t x)
Reverses the byte order of the 64-bit unsigned integer x.
Definition: bits.h:308
uint_least16_t ldle_u16(const uint_least8_t src[2])
Loads a 16-bit unsigned integer in little-endian byte order.
Definition: endian.h:506
void stbe_u32(uint_least8_t dst[4], uint_least32_t x)
Stores a 32-bit unsigned integer in big-endian byte order.
Definition: endian.h:531
uint_least64_t ldbe_u64(const uint_least8_t src[8])
Loads a 64-bit unsigned integer in big-endian byte order.
Definition: endian.h:631
void stle_u16(uint_least8_t dst[2], uint_least16_t x)
Stores a 16-bit unsigned integer in little-endian byte order.
Definition: endian.h:494
uint_least32_t ldbe_u32(const uint_least8_t src[4])
Loads a 32-bit unsigned integer in big-endian byte order.
Definition: endian.h:545
This header file is part of the utilities library; it contains the IEEE 754 floating-point format typ...
void stbe_i64(uint_least8_t dst[8], int_least64_t x)
Stores a 64-bit signed integer in big-endian byte order.
Definition: endian.h:601
uint_least64_t htobe64(uint_least64_t x)
Converts a 64-bit unsigned integer from host to big-endian byte order.
Definition: endian.h:404
void stle_i32(uint_least8_t dst[4], int_least32_t x)
Stores a 32-bit signed integer in little-endian byte order.
Definition: endian.h:560
void bcpybe(uint_least8_t *dst, int dstbit, const uint_least8_t *src, int srcbit, size_t n)
Copies n bits from a source to a destination buffer.
Definition: endian.c:39
void stbe_i32(uint_least8_t dst[4], int_least32_t x)
Stores a 32-bit signed integer in big-endian byte order.
Definition: endian.h:519
void bcpyle(uint_least8_t *dst, int dstbit, const uint_least8_t *src, int srcbit, size_t n)
Copies n bits from a source to a destination buffer.
Definition: endian.c:123
int_least32_t ldbe_i32(const uint_least8_t src[4])
Loads a 32-bit signed integer in big-endian byte order.
Definition: endian.h:525
void stle_i16(uint_least8_t dst[2], int_least16_t x)
Stores a 16-bit signed integer in little-endian byte order.
Definition: endian.h:482
uint_least16_t htobe16(uint_least16_t x)
Converts a 16-bit unsigned integer from host to big-endian byte order.
Definition: endian.h:320
uint_least16_t ldbe_u16(const uint_least8_t src[2])
Loads a 16-bit unsigned integer in big-endian byte order.
Definition: endian.h:469
int_least16_t ldbe_i16(const uint_least8_t src[2])
Loads a 16-bit signed integer in big-endian byte order.
Definition: endian.h:451
void stle_u64(uint_least8_t dst[8], uint_least64_t x)
Stores a 64-bit unsigned integer in little-endian byte order.
Definition: endian.h:662
void stbe_u64(uint_least8_t dst[8], uint_least64_t x)
Stores a 64-bit unsigned integer in big-endian byte order.
Definition: endian.h:613
void stle_i64(uint_least8_t dst[8], int_least64_t x)
Stores a 64-bit signed integer in little-endian byte order.
Definition: endian.h:650
void stle_u32(uint_least8_t dst[4], uint_least32_t x)
Stores a 32-bit unsigned integer in little-endian byte order.
Definition: endian.h:572
uint_least64_t betoh64(uint_least64_t x)
Converts a 64-bit unsigned integer from big-endian to host byte order.
Definition: endian.h:417
uint_least32_t htole32(uint_least32_t x)
Converts a 32-bit unsigned integer from host to little-endian byte order.
Definition: endian.h:383
uint_least16_t letoh16(uint_least16_t x)
Converts a 16-bit unsigned integer from little-endian to host byte order.
Definition: endian.h:354
This header file is part of the utilities library; it contains the bit function definitions.
uint_least32_t bswap32(uint_least32_t x)
Reverses the byte order of the 32-bit unsigned integer x.
Definition: bits.h:295
uint_least16_t bswap16(uint_least16_t x)
Reverses the byte order of the 16-bit unsigned integer x.
Definition: bits.h:283
uint_least64_t letoh64(uint_least64_t x)
Converts a 64-bit unsigned integer from little-endian to host byte order.
Definition: endian.h:438
int_least64_t ldbe_i64(const uint_least8_t src[8])
Loads a 64-bit signed integer in big-endian byte order.
Definition: endian.h:607
int_least32_t ldle_i32(const uint_least8_t src[4])
Loads a 32-bit signed integer in little-endian byte order.
Definition: endian.h:566
uint_least16_t betoh16(uint_least16_t x)
Converts a 16-bit unsigned integer from big-endian to host byte order.
Definition: endian.h:333
int_least64_t ldle_i64(const uint_least8_t src[8])
Loads a 64-bit signed integer in little-endian byte order.
Definition: endian.h:656
uint_least64_t ldle_u64(const uint_least8_t src[8])
Loads a 64-bit unsigned integer in little-endian byte order.
Definition: endian.h:680
int_least16_t ldle_i16(const uint_least8_t src[2])
Loads a 16-bit signed integer in little-endian byte order.
Definition: endian.h:488
uint_least32_t htobe32(uint_least32_t x)
Converts a 32-bit unsigned integer from host to big-endian byte order.
Definition: endian.h:362
uint_least32_t ldle_u32(const uint_least8_t src[4])
Loads a 32-bit unsigned integer in little-endian byte order.
Definition: endian.h:586
uint_least64_t htole64(uint_least64_t x)
Converts a 64-bit unsigned integer from host to little-endian byte order.
Definition: endian.h:425