lkml.org 
[lkml]   [2011]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] add slice by 8 algorithm to crc32.c
> -#define LE_TABLE_SIZE (1 << CRC_LE_BITS)
> -#define BE_TABLE_SIZE (1 << CRC_BE_BITS)
> +#if CRC_LE_BITS > 8
> +# define LE_TABLE_SIZE 256
> +#else
> +# define LE_TABLE_SIZE (1 << CRC_LE_BITS)
> +#endif
> +#if CRC_BE_BITS > 8
> +# define BE_TABLE_SIZE 256
> +#else
> +# define BE_TABLE_SIZE (1 << CRC_BE_BITS)
> +#endif
>
> -static uint32_t crc32table_le[4][LE_TABLE_SIZE];
> -static uint32_t crc32table_be[4][BE_TABLE_SIZE];
> +#define LE_TABLE_ROWS ((CRC_LE_BITS - 1)/8 + 1)
> +#define BE_TABLE_ROWS ((CRC_BE_BITS - 1)/8 + 1)
> +
> +static uint32_t crc32table_le[LE_TABLE_ROWS][LE_TABLE_SIZE];
> +static uint32_t crc32table_be[BE_TABLE_ROWS][BE_TABLE_SIZE];

Minor cleanup suggestion: The two different ways of computing
xE_TABLE_SIZE and xE_TABLE_ROWS is a bit confusing.

May I recommend choosing one of the following:

#if CRC_LE_BITS > 8
# define LE_TABLE_ROWS (CRC_LE_BITS/8)
# define LE_TABLE_SIZE 256
#else
# define LE_TABLE_ROWS 1
# define LE_TABLE_SIZE (1 << CRC_LE_BITS)
#endif

or

#define LE_TABLE_ROWS ((CRC_LE_BITS - 1)/8 + 1)
#define LE_TABLE_SIZE (1 << ((CRC_LE_BITS - 1)%8 + 1))

Either one makes the relationship between the two clearer.


\
 
 \ /
  Last update: 2011-08-08 14:57    [W:0.062 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site