ObjFW  Diff

Differences From Artifact [93351baa39]:

To Artifact [793bb737f0]:


202
203
204
205
206
207
208














209
210
211
212
213
214
215
# define of_bswap64(i) \
	(__builtin_constant_p(i) ? of_bswap64_const(i) : of_bswap64_nonconst(i))
#else
# define of_bswap16(i) of_bswap16_const(i)
# define of_bswap32(i) of_bswap32_const(i)
# define of_bswap64(i) of_bswap64_const(i)
#endif















static OF_INLINE void
of_bswap32_vec(uint32_t *buffer, size_t length)
{
	while (length--) {
		*buffer = of_bswap32(*buffer);
		buffer++;







>
>
>
>
>
>
>
>
>
>
>
>
>
>







202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# define of_bswap64(i) \
	(__builtin_constant_p(i) ? of_bswap64_const(i) : of_bswap64_nonconst(i))
#else
# define of_bswap16(i) of_bswap16_const(i)
# define of_bswap32(i) of_bswap32_const(i)
# define of_bswap64(i) of_bswap64_const(i)
#endif

static OF_INLINE float OF_CONST_FUNC
of_bswap_float(float f)
{
	uint32_t tmp = of_bswap32(*(uint32_t*)&f);
	return *(float*)&tmp;
}

static OF_INLINE double OF_CONST_FUNC
of_bswap_double(double d)
{
	uint64_t tmp = of_bswap64(*(uint64_t*)&d);
	return *(double*)&tmp;
}

static OF_INLINE void
of_bswap32_vec(uint32_t *buffer, size_t length)
{
	while (length--) {
		*buffer = of_bswap32(*buffer);
		buffer++;
229
230
231
232
233
234
235












236
237
238
239
240
241
242
# define of_bswap32_if_be(i) (i)
# define of_bswap64_if_be(i) (i)
# define of_bswap16_if_le(i) of_bswap16(i)
# define of_bswap32_if_le(i) of_bswap32(i)
# define of_bswap64_if_le(i) of_bswap64(i)
# define of_bswap32_vec_if_be(buffer, length)
#endif













#define OF_ROL(value, bits)						\
	(((value) << ((bits) % (sizeof(value) * 8))) |			\
	(value) >> (sizeof(value) * 8 - ((bits) % (sizeof(value) * 8))))

#define OF_HASH_INIT(hash) hash = 0
#define OF_HASH_ADD(hash, byte)		\







>
>
>
>
>
>
>
>
>
>
>
>







243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# define of_bswap32_if_be(i) (i)
# define of_bswap64_if_be(i) (i)
# define of_bswap16_if_le(i) of_bswap16(i)
# define of_bswap32_if_le(i) of_bswap32(i)
# define of_bswap64_if_le(i) of_bswap64(i)
# define of_bswap32_vec_if_be(buffer, length)
#endif

#ifdef OF_FLOAT_BIG_ENDIAN
# define of_bswap_float_if_be(i) of_bswap_float(i)
# define of_bswap_double_if_be(i) of_bswap_double(i)
# define of_bswap_float_if_le(i) (i)
# define of_bswap_double_if_le(i) (i)
#else
# 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

#define OF_ROL(value, bits)						\
	(((value) << ((bits) % (sizeof(value) * 8))) |			\
	(value) >> (sizeof(value) * 8 - ((bits) % (sizeof(value) * 8))))

#define OF_HASH_INIT(hash) hash = 0
#define OF_HASH_ADD(hash, byte)		\