ObjFW  Diff

Differences From Artifact [8a33280748]:

To Artifact [ed1d1a5d46]:


104
105
106
107
108
109
110
111

112
113

114
115
116
117
118
119
120
104
105
106
107
108
109
110

111
112

113
114
115
116
117
118
119
120







-
+

-
+







# else
#  /* Hopefully no arch needs more than 16 byte alignment */
#  define OF_BIGGEST_ALIGNMENT 16
# endif
#endif

#ifdef __GNUC__
# define __GCC_VERSION__ (__GNUC__ * 100 + __GNUC_MINOR__)
# define OF_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#else
# define __GCC_VERSION__ 0
# define OF_GCC_VERSION 0
#endif

#ifndef __has_feature
# define __has_feature(x) 0
#endif

#ifndef __has_attribute
194
195
196
197
198
199
200
201

202
203
204
205
206
207

208
209
210
211
212
213
214
194
195
196
197
198
199
200

201
202
203
204
205
206

207
208
209
210
211
212
213
214







-
+





-
+








#if __has_feature(objc_kindof)
# define OF_KINDOF(cls) __kindof cls
#else
# define OF_KINDOF(cls) id
#endif

#if defined(__clang__) || __GCC_VERSION__ >= 405
#if defined(__clang__) || OF_GCC_VERSION >= 405
# define OF_UNREACHABLE __builtin_unreachable();
#else
# define OF_UNREACHABLE abort();
#endif

#if defined(__clang__) || __GCC_VERSION__ >= 406
#if defined(__clang__) || OF_GCC_VERSION >= 406
# define OF_SENTINEL __attribute__((__sentinel__))
# define OF_NO_RETURN __attribute__((__noreturn__))
#else
# define OF_SENTINEL
# define OF_NO_RETURN
#endif

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
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







-
+

-
+



-
+

-
+



-
+

-
+


-
-
+
+













-
+







		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 idx)
{
	return storage[index / 8] & (1 << (index % 8));
	return storage[idx / 8] & (1 << (idx % 8));
}

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

static OF_INLINE void
of_bitset_clear(uint8_t *storage, size_t index)
of_bitset_clear(uint8_t *_Nonnull storage, size_t idx)
{
	storage[index / 8] &= ~(1 << (index % 8));
	storage[idx / 8] &= ~(1 << (idx % 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;
}