Re: CRC algorithm (was Re: [REVIEW] Re: Compression of full-page-writes)

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: CRC algorithm (was Re: [REVIEW] Re: Compression of full-page-writes)
Дата
Msg-id 20140916105705.GA25775@awork2.anarazel.de
обсуждение исходный текст
Ответ на Re: CRC algorithm (was Re: [REVIEW] Re: Compression of full-page-writes)  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Ответы Re: CRC algorithm (was Re: [REVIEW] Re: Compression of full-page-writes)  (Amit Kapila <amit.kapila16@gmail.com>)
Список pgsql-hackers
On 2014-09-16 13:49:20 +0300, Heikki Linnakangas wrote:
> I used http://create.stephan-brumme.com/crc32/#slicing-by-8-overview as
> reference - you can probably see the similarity. Any implementation is going
> to look more or less the same, though; there aren't that many ways to write
> the implementation.

True.

I think I see what's the problem causing Amit's test to fail. Amit, did
you use the powerpc machine?

Heikki, you swap bytes unconditionally - afaics that's wrong on big
endian systems. My patch had:

+ static inline uint32 swab32(const uint32 x);
+ static inline uint32 swab32(const uint32 x){
+     return ((x & (uint32)0x000000ffUL) << 24) |
+         ((x & (uint32)0x0000ff00UL) <<  8) |
+         ((x & (uint32)0x00ff0000UL) >>  8) |
+         ((x & (uint32)0xff000000UL) >> 24);
+ }
+ 
+ #if defined __BIG_ENDIAN__
+ #define cpu_to_be32(x)
+ #else
+ #define cpu_to_be32(x) swab32(x)
+ #endif


I guess yours needs something similar. I personally like the cpu_to_be*
naming - it imo makes it pretty clear what happens.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: CRC algorithm (was Re: [REVIEW] Re: Compression of full-page-writes)
Следующее
От: Etsuro Fujita
Дата:
Сообщение: Minor improvement in lock.sgml