ObjFW  Check-in [2d936d7aa7]

Overview
Comment:Fix bug I didn't notice thanks to gcc 4.2.

It seems gcc 4.2 globals the variables from the caller of an inline
function to the inline function.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2d936d7aa75603f60aad4fb930902ea8b854bc361b5a2f0f18b5c3150c57c6af
User & Date: js on 2008-11-01 20:16:56
Other Links: manifest | tags
Context
2008-11-01
20:29
Delete .deps on make distclean. check-in: 88bad9ba54 user: js tags: trunk
20:16
Fix bug I didn't notice thanks to gcc 4.2. check-in: 2d936d7aa7 user: js tags: trunk
20:12
Don't delete .deps file on make clean. check-in: e911d987b5 user: js tags: trunk
Changes

Modified src/OFHashes.m from [f95a522750] to [4f4ce61c2e].

326
327
328
329
330
331
332

333
334
335
336
337
338
339
340
341
342
343
344
345
	state[1] += b;
	state[2] += c;
	state[3] += d;
	state[4] += e;
}

static inline void

sha1_update(uint8_t buffer, const uint8_t *buf, size_t size)
{
	size_t i, j;

	j = (size_t)((count >> 3) & 63);
	count += (size << 3);

	if ((j + size) > 63) {
		memcpy(&buffer[j], buf, (i = 64 - j));

		sha1_transform(state, buffer);

		for (; i + 63 < size; i += 64)







>
|



|
|







326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
	state[1] += b;
	state[2] += c;
	state[3] += d;
	state[4] += e;
}

static inline void
sha1_update(uint32_t *state, uint64_t *count, uint8_t *buffer,
    const uint8_t *buf, size_t size)
{
	size_t i, j;

	j = (size_t)((*count >> 3) & 63);
	*count += (size << 3);

	if ((j + size) > 63) {
		memcpy(&buffer[j], buf, (i = 64 - j));

		sha1_transform(state, buffer);

		for (; i + 63 < size; i += 64)
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
	    ofSize: (size_t)size
{
	if (calculated)
		return self;
	if (size == 0)
		return self;

	sha1_update(buffer, buf, size);

	return self;
}

- (uint8_t*)digest
{
	size_t i;
	uint8_t finalcount[8];

	if (calculated)
		return digest;

	for (i = 0; i < 8; i++)
		/* Endian independent */
		finalcount[i] = (uint8_t)((count >> ((7 - (i & 7)) * 8)) & 255);
	sha1_update(buffer, (const uint8_t*)"\200", 1);

	while ((count & 504) != 448)
		sha1_update(buffer, (const uint8_t*)"\0", 1);
	/* Should cause a sha1_transform() */
	sha1_update(buffer, finalcount, 8);

	for (i = 0; i < SHA1_DIGEST_SIZE; i++)
		digest[i] = (uint8_t)((state[i >> 2] >>
		    ((3 - (i & 3)) * 8)) & 255);

	return digest;
}







|















|


|

|







372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
	    ofSize: (size_t)size
{
	if (calculated)
		return self;
	if (size == 0)
		return self;

	sha1_update(state, &count, buffer, buf, size);

	return self;
}

- (uint8_t*)digest
{
	size_t i;
	uint8_t finalcount[8];

	if (calculated)
		return digest;

	for (i = 0; i < 8; i++)
		/* Endian independent */
		finalcount[i] = (uint8_t)((count >> ((7 - (i & 7)) * 8)) & 255);
	sha1_update(state, &count, buffer, (const uint8_t*)"\200", 1);

	while ((count & 504) != 448)
		sha1_update(state, &count, buffer, (const uint8_t*)"\0", 1);
	/* Should cause a sha1_transform() */
	sha1_update(state, &count, buffer, finalcount, 8);

	for (i = 0; i < SHA1_DIGEST_SIZE; i++)
		digest[i] = (uint8_t)((state[i >> 2] >>
		    ((3 - (i & 3)) * 8)) & 255);

	return digest;
}