ObjFW  Diff

Differences From Artifact [7f6db52639]:

To Artifact [ffa2588354]:


573
574
575
576
577
578
579
580

581
582
583
584
585
586
587
588

589
590
591
592
593
594
595
596

597
598
599
600
601
602
603
604

605
606
607
608
609
610
611
612

613
614
615
616
617
618
619
620

621
622
623
624
625
626
627
628

629
630
631
632
633
634
635
636

637
638
639
640
641
642
643
644

645
646
647
648
649
650
651
652

653
654
655
656
657
658
659
660

661
662
663
664
665
666
667

668
669
670
671
672
673
674

675
676
677
678
679
680
681

682
683
684
685
686
687
688

689
690
691
692
693
694
695

696
697
698
699
700
701
702

703
704
705
706
707
708
709

710
711
712
713
714
715
716

717
718
719
720
721
722
723

724
725
726
727
728
729
730
573
574
575
576
577
578
579

580
581
582
583
584
585
586
587

588
589
590
591
592
593
594
595

596
597
598
599
600
601
602
603

604
605
606
607
608
609
610
611

612
613
614
615
616
617
618
619

620
621
622
623
624
625
626
627

628
629
630
631
632
633
634
635

636
637
638
639
640
641
642
643

644
645
646
647
648
649
650
651

652
653
654
655
656
657
658
659

660
661
662
663
664
665
666

667
668
669
670
671
672
673

674
675
676
677
678
679
680

681
682
683
684
685
686
687

688
689
690
691
692
693
694

695
696
697
698
699
700
701

702
703
704
705
706
707
708

709
710
711
712
713
714
715

716
717
718
719
720
721
722

723
724
725
726
727
728
729
730







-
+







-
+







-
+







-
+







-
+







-
+







-
+







-
+







-
+







-
+







-
+






-
+






-
+






-
+






-
+






-
+






-
+






-
+






-
+






-
+







# define OF_BSWAP_FLOAT_IF_BE(i) (i)
# define OF_BSWAP_DOUBLE_IF_BE(i) (i)
# define OF_BSWAP_FLOAT_IF_LE(i) OF_BSWAP_FLOAT(i)
# define OF_BSWAP_DOUBLE_IF_LE(i) OF_BSWAP_DOUBLE(i)
#endif

static OF_INLINE uint16_t
of_be16_ptr_read(void *ptr)
of_be16_ptr_read(void *_Nonnull ptr)
{
	uint16_t value;
	memcpy(&value, ptr, sizeof(value));
	return OF_BSWAP16_IF_LE(value);
}

static OF_INLINE uint32_t
of_be32_ptr_read(void *ptr)
of_be32_ptr_read(void *_Nonnull ptr)
{
	uint32_t value;
	memcpy(&value, ptr, sizeof(value));
	return OF_BSWAP32_IF_LE(value);
}

static OF_INLINE uint64_t
of_be64_ptr_read(void *ptr)
of_be64_ptr_read(void *_Nonnull ptr)
{
	uint64_t value;
	memcpy(&value, ptr, sizeof(value));
	return OF_BSWAP64_IF_LE(value);
}

static OF_INLINE float
of_be_float_ptr_read(void *ptr)
of_be_float_ptr_read(void *_Nonnull ptr)
{
	float value;
	memcpy(&value, ptr, sizeof(value));
	return OF_BSWAP_FLOAT_IF_LE(value);
}

static OF_INLINE double
of_be_double_ptr_read(void *ptr)
of_be_double_ptr_read(void *_Nonnull ptr)
{
	double value;
	memcpy(&value, ptr, sizeof(value));
	return OF_BSWAP_DOUBLE_IF_LE(value);
}

static OF_INLINE uint16_t
of_le16_ptr_read(void *ptr)
of_le16_ptr_read(void *_Nonnull ptr)
{
	uint16_t value;
	memcpy(&value, ptr, sizeof(value));
	return OF_BSWAP16_IF_BE(value);
}

static OF_INLINE uint32_t
of_le32_ptr_read(void *ptr)
of_le32_ptr_read(void *_Nonnull ptr)
{
	uint32_t value;
	memcpy(&value, ptr, sizeof(value));
	return OF_BSWAP32_IF_BE(value);
}

static OF_INLINE uint64_t
of_le64_ptr_read(void *ptr)
of_le64_ptr_read(void *_Nonnull ptr)
{
	uint64_t value;
	memcpy(&value, ptr, sizeof(value));
	return OF_BSWAP64_IF_BE(value);
}

static OF_INLINE float
of_le_float_ptr_read(void *ptr)
of_le_float_ptr_read(void *_Nonnull ptr)
{
	float value;
	memcpy(&value, ptr, sizeof(value));
	return OF_BSWAP_FLOAT_IF_BE(value);
}

static OF_INLINE double
of_le_double_ptr_read(void *ptr)
of_le_double_ptr_read(void *_Nonnull ptr)
{
	double value;
	memcpy(&value, ptr, sizeof(value));
	return OF_BSWAP_DOUBLE_IF_BE(value);
}

static OF_INLINE void
of_be16_ptr_write(void *ptr, uint16_t value)
of_be16_ptr_write(void *_Nonnull ptr, uint16_t value)
{
	value = OF_BSWAP16_IF_LE(value);
	memcpy(ptr, &value, sizeof(value));
}

static OF_INLINE void
of_be32_ptr_write(void *ptr, uint32_t value)
of_be32_ptr_write(void *_Nonnull ptr, uint32_t value)
{
	value = OF_BSWAP32_IF_LE(value);
	memcpy(ptr, &value, sizeof(value));
}

static OF_INLINE void
of_be64_ptr_write(void *ptr, uint64_t value)
of_be64_ptr_write(void *_Nonnull ptr, uint64_t value)
{
	value = OF_BSWAP64_IF_LE(value);
	memcpy(ptr, &value, sizeof(value));
}

static OF_INLINE void
of_be_float_ptr_write(void *ptr, float value)
of_be_float_ptr_write(void *_Nonnull ptr, float value)
{
	value = OF_BSWAP_FLOAT_IF_LE(value);
	memcpy(ptr, &value, sizeof(value));
}

static OF_INLINE void
of_be_double_ptr_write(void *ptr, double value)
of_be_double_ptr_write(void *_Nonnull ptr, double value)
{
	value = OF_BSWAP_DOUBLE_IF_LE(value);
	memcpy(ptr, &value, sizeof(value));
}

static OF_INLINE void
of_le16_ptr_write(void *ptr, uint16_t value)
of_le16_ptr_write(void *_Nonnull ptr, uint16_t value)
{
	value = OF_BSWAP16_IF_BE(value);
	memcpy(ptr, &value, sizeof(value));
}

static OF_INLINE void
of_le32_ptr_write(void *ptr, uint32_t value)
of_le32_ptr_write(void *_Nonnull ptr, uint32_t value)
{
	value = OF_BSWAP32_IF_BE(value);
	memcpy(ptr, &value, sizeof(value));
}

static OF_INLINE void
of_le64_ptr_write(void *ptr, uint64_t value)
of_le64_ptr_write(void *_Nonnull ptr, uint64_t value)
{
	value = OF_BSWAP64_IF_BE(value);
	memcpy(ptr, &value, sizeof(value));
}

static OF_INLINE void
of_le_float_ptr_write(void *ptr, float value)
of_le_float_ptr_write(void *_Nonnull ptr, float value)
{
	value = OF_BSWAP_FLOAT_IF_BE(value);
	memcpy(ptr, &value, sizeof(value));
}

static OF_INLINE void
of_le_double_ptr_write(void *ptr, double value)
of_le_double_ptr_write(void *_Nonnull ptr, double value)
{
	value = OF_BSWAP_DOUBLE_IF_BE(value);
	memcpy(ptr, &value, sizeof(value));
}

#define OF_ROL(value, bits)						\
    (((bits) % (sizeof(value) * 8)) > 0					\
758
759
760
761
762
763
764
765

766
767
768
769
770
771

772
773
774
775
776
777

778
779
780
781
782
783


784
785
786
787
788
789
790
791
792
793
794
795
796
797

798
799
800
801
802
803
804
758
759
760
761
762
763
764

765
766
767
768
769
770

771
772
773
774
775
776

777
778
779
780
781


782
783
784
785
786
787
788
789
790
791
792
793
794
795
796

797
798
799
800
801
802
803
804







-
+





-
+





-
+




-
-
+
+













-
+







		OF_HASH_ADD(hash, (otherCopy >> 24) & 0xFF);	\
		OF_HASH_ADD(hash, (otherCopy >> 16) & 0xFF);	\
		OF_HASH_ADD(hash, (otherCopy >>  8) & 0xFF);	\
		OF_HASH_ADD(hash, otherCopy & 0xFF);		\
	}

static OF_INLINE bool
of_bitset_isset(uint8_t *storage, size_t index)
of_bitset_isset(uint8_t *_Nonnull storage, size_t index)
{
	return storage[index / 8] & (1 << (index % 8));
}

static OF_INLINE void
of_bitset_set(uint8_t *storage, size_t index)
of_bitset_set(uint8_t *_Nonnull storage, size_t index)
{
	storage[index / 8] |= (1 << (index % 8));
}

static OF_INLINE void
of_bitset_clear(uint8_t *storage, size_t index)
of_bitset_clear(uint8_t *_Nonnull storage, size_t index)
{
	storage[index / 8] &= ~(1 << (index % 8));
}

static OF_INLINE char *
of_strdup(const char *string)
static OF_INLINE char *_Nullable
of_strdup(const char *_Nonnull string)
{
	char *copy;
	size_t length = strlen(string);

	if ((copy = (char *)malloc(length + 1)) == NULL)
		return NULL;

	memcpy(copy, string, length + 1);

	return copy;
}

static OF_INLINE void
of_explicit_memset(void *buffer_, int character, size_t length)
of_explicit_memset(void *_Nonnull buffer_, int character, size_t length)
{
	volatile unsigned char *buffer = (volatile unsigned char *)buffer_;

	while (buffer < (unsigned char *)buffer_ + length)
		*buffer++ = character;
}