-#ifdef W
-
-/*
- Swap the bytes in a z_word_t to convert between little and big endian. Any
- self-respecting compiler will optimize this to a single machine byte-swap
- instruction, if one is available. This assumes that word_t is either 32 bits
- or 64 bits.
- */
-local z_word_t byte_swap(word)
- z_word_t word;
-{
-#if W == 8
- return
- (word & 0xff00000000000000) >> 56 |
- (word & 0xff000000000000) >> 40 |
- (word & 0xff0000000000) >> 24 |
- (word & 0xff00000000) >> 8 |
- (word & 0xff000000) << 8 |
- (word & 0xff0000) << 24 |
- (word & 0xff00) << 40 |
- (word & 0xff) << 56;
-#else /* W == 4 */
- return
- (word & 0xff000000) >> 24 |
- (word & 0xff0000) >> 8 |
- (word & 0xff00) << 8 |
- (word & 0xff) << 24;
-#endif
-}
-
-/*
- Return the CRC of the W bytes in the word_t data, taking the
- least-significant byte of the word as the first byte of data, without any pre
- or post conditioning. This is used to combine the CRCs of each braid.
- */
-local z_crc_t crc_word(data)
- z_word_t data;
-{
- int k;
- for (k = 0; k < W; k++)
- data = (data >> 8) ^ crc_table[data & 0xff];
- return (z_crc_t)data;
-}
-
-local z_word_t crc_word_big(data)
- z_word_t data;
-{
- int k;
- for (k = 0; k < W; k++)
- data = (data << 8) ^
- crc_big_table[(data >> ((W - 1) << 3)) & 0xff];
- return data;
-}
-
-#endif /* W */
-