* Mirror the bottom n bits of x. */
| 329 | * Mirror the bottom n bits of x. |
| 330 | */ |
| 331 | static unsigned long mirror (unsigned long x, int n) { |
| 332 | unsigned long top = 1 << (n-1), bottom = 1; |
| 333 | while (top > bottom) { |
| 334 | unsigned long mask = top | bottom; |
| 335 | unsigned long masked = x & mask; |
| 336 | if (masked != 0 && masked != mask) |
| 337 | x ^= mask; |
| 338 | top >>= 1; |
| 339 | bottom <<= 1; |
| 340 | } |
| 341 | return x; |
| 342 | } |
| 343 | |
| 344 | /* |
| 345 | * Calculate a CRC, the RNC way. It re-computes its CRC table every |