36 #if defined( INC_ALL )
46 #if defined( GF_MODE_LL )
48 #elif defined( GF_MODE_BL )
50 #elif defined( GF_MODE_LB )
52 #elif defined( GF_MODE_BB )
55 # error mode is not defined
58 #if defined( GF_MODE_LL) || defined( GF_MODE_LB )
59 # define GF_INDEX(i) (i)
61 # define GF_INDEX(i) (15 - (i))
72 for(i = 0; i < 7; ++i)
75 q = (uint_8t*)(a == b ? p[0] : b);
102 #if defined( TABLES_64K )
131 #if defined( GF_MODE_LL ) || defined( GF_MODE_BL )
135 for(j = 1; j <= 64; j <<= 1)
141 for(j = 64; j >= 1; j >>= 1)
163 for(j = 2; j < 256; j += j)
164 for(k = 1; k < j; ++k)
175 for(j = 128; j > 0; j >>= 1)
183 #define xor_64k(i,ap,t,r) xor_block_aligned(r, r, t[i][ap[GF_INDEX(i)]])
185 #if defined( UNROLL_LOOPS )
188 { uint_8t *ap = (uint_8t*)a;
190 xor_64k(15, ap, t, r); xor_64k(14, ap, t, r);
191 xor_64k(13, ap, t, r); xor_64k(12, ap, t, r);
192 xor_64k(11, ap, t, r); xor_64k(10, ap, t, r);
193 xor_64k( 9, ap, t, r); xor_64k( 8, ap, t, r);
194 xor_64k( 7, ap, t, r); xor_64k( 6, ap, t, r);
195 xor_64k( 5, ap, t, r); xor_64k( 4, ap, t, r);
196 xor_64k( 3, ap, t, r); xor_64k( 2, ap, t, r);
197 xor_64k( 1, ap, t, r); xor_64k( 0, ap, t, r);
205 uint_8t *ap = (uint_8t*)a;
207 for(i = 15; i >= 0; --i)
218 #if defined( TABLES_8K )
241 #if defined( GF_MODE_LL ) || defined( GF_MODE_BL )
245 for(j = 1; j <= 4; j <<= 1)
249 for(j = 1; j <= 4; j <<= 1)
255 for(j = 4; j >= 1; j >>= 1)
259 for(j = 4; j >= 1; j >>= 1)
265 for(j = 2; j < 16; j += j)
266 for(k = 1; k < j; ++k)
275 for(j = 8; j > 0; j >>= 1)
285 #define xor_8k(i,ap,t,r) \
286 xor_block_aligned(r, r, t[i + i][ap[GF_INDEX(i)] & 15]); \
287 xor_block_aligned(r, r, t[i + i + 1][ap[GF_INDEX(i)] >> 4])
289 #if defined( UNROLL_LOOPS )
292 { uint_8t *ap = (uint_8t*)a;
294 xor_8k(15, ap, t, r); xor_8k(14, ap, t, r);
295 xor_8k(13, ap, t, r); xor_8k(12, ap, t, r);
296 xor_8k(11, ap, t, r); xor_8k(10, ap, t, r);
297 xor_8k( 9, ap, t, r); xor_8k( 8, ap, t, r);
298 xor_8k( 7, ap, t, r); xor_8k( 6, ap, t, r);
299 xor_8k( 5, ap, t, r); xor_8k( 4, ap, t, r);
300 xor_8k( 3, ap, t, r); xor_8k( 2, ap, t, r);
301 xor_8k( 1, ap, t, r); xor_8k( 0, ap, t, r);
309 uint_8t *ap = (uint_8t*)a;
311 for(i = 15; i >= 0; --i)
322 #if defined( TABLES_4K )
349 #if defined( GF_MODE_LL ) || defined( GF_MODE_BL )
352 for(j = 1; j <= 64; j <<= 1)
357 for(j = 64; j >= 1; j >>= 1)
361 for(j = 2; j < 256; j += j)
362 for(k = 1; k < j; ++k)
366 #define xor_4k(i,ap,t,r) gf_mulx8(mode)(r); xor_block_aligned(r, r, t[ap[GF_INDEX(i)]])
368 #if defined( UNROLL_LOOPS )
371 { uint_8t *ap = (uint_8t*)a;
373 xor_4k(15, ap, t, r); xor_4k(14, ap, t, r);
374 xor_4k(13, ap, t, r); xor_4k(12, ap, t, r);
375 xor_4k(11, ap, t, r); xor_4k(10, ap, t, r);
376 xor_4k( 9, ap, t, r); xor_4k( 8, ap, t, r);
377 xor_4k( 7, ap, t, r); xor_4k( 6, ap, t, r);
378 xor_4k( 5, ap, t, r); xor_4k( 4, ap, t, r);
379 xor_4k( 3, ap, t, r); xor_4k( 2, ap, t, r);
380 xor_4k( 1, ap, t, r); xor_4k( 0, ap, t, r);
388 uint_8t *ap = (uint_8t*)a;
390 for(i = 15; i >=0; --i)
401 #if defined( TABLES_256 )
426 #if defined( GF_MODE_LL ) || defined( GF_MODE_BL )
429 for(j = 1; j <= 4; j <<= 1)
434 for(j = 4; j >= 1; j >>= 1)
438 for(j = 2; j < 16; j += j)
439 for(k = 1; k < j; ++k)
443 #define x_lo(i,ap,t,r) gf_mulx4(mode)(r); xor_block_aligned(r, r, t[ap[GF_INDEX(i)] & 0x0f])
444 #define x_hi(i,ap,t,r) gf_mulx4(mode)(r); xor_block_aligned(r, r, t[ap[GF_INDEX(i)] >> 4])
446 #if defined( GF_MODE_LL ) || defined( GF_MODE_BL )
447 #define xor_256(a,b,c,d) x_hi(a,b,c,d); x_lo(a,b,c,d)
449 #define xor_256(a,b,c,d) x_lo(a,b,c,d); x_hi(a,b,c,d)
452 #if defined( UNROLL_LOOPS )
455 { uint_8t *ap = (uint_8t*)a;
457 xor_256(15, ap, t, r); xor_256(14, ap, t, r);
458 xor_256(13, ap, t, r); xor_256(12, ap, t, r);
459 xor_256(11, ap, t, r); xor_256(10, ap, t, r);
460 xor_256( 9, ap, t, r); xor_256( 8, ap, t, r);
461 xor_256( 7, ap, t, r); xor_256( 6, ap, t, r);
462 xor_256( 5, ap, t, r); xor_256( 4, ap, t, r);
463 xor_256( 3, ap, t, r); xor_256( 2, ap, t, r);
464 xor_256( 1, ap, t, r); xor_256( 0, ap, t, r);
472 uint_8t *ap = (uint_8t*)a;
474 for(i = 15; i >= 0; --i)
476 xor_256(i, ap, t, r);