RE: [PATCH 0/1] Add KUnit tests for lib/crc16.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



...
> The checksums for the randomly-generated test cases were calculated
> using a reference implementation [1] and this test compares them against
> the values yielded by the kernel's implementation.

I'd just use a naïve implementation - doesn't really matter
if it is a bit slow.

Slow is relative - this code only takes 35ms to crc-64 over 5MB of data.

{
    volatile const uint32_t *r = (const void *)buf;
    for (crc = 0; r < (const uint32_t *)buf_end; r++) {
        uint64_t val = le32toh(*r);
        crc ^= bswap64(val);
        for (i = 0; i < 32; i++) {
            if (crc & (1ull << 63))
                crc = (crc << 1) ^ 0x42f0e1eba9ea3693ull;
            else
                crc = crc << 1;
        }
    }
}

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux