56 #if uword_bits != 32 && uword_bits != 64 57 #error "isaac only works for 32 or 64 bit words" 62 #define ind32(mm,x) (*(u32 *)((u8 *)(mm) + ((x) & ((ISAAC_SIZE-1)<<2)))) 63 #define rngstep32(mix,a,b,mm,m,m2,r,x,y) \ 66 a = (a^(mix)) + *(m2++); \ 67 *(m++) = y = ind32(mm,x) + a + b; \ 68 *(r++) = b = ind32(mm,y>>ISAAC_LOG2_SIZE) + x; \ 73 u32 a, b, c, x,
y, * m, * mm, * m2, * r, * mend;
86 rngstep32 (a<<13, a, b, mm, m, m2, r, x, y);
87 rngstep32 (a>>6 , a, b, mm, m, m2, r, x, y);
88 rngstep32 (a<<2 , a, b, mm, m, m2, r, x, y);
89 rngstep32 (a>>16, a, b, mm, m, m2, r, x, y);
95 rngstep32 (a<<13, a, b, mm, m, m2, r, x, y);
96 rngstep32 (a>>6 , a, b, mm, m, m2, r, x, y);
97 rngstep32 (a<<2 , a, b, mm, m, m2, r, x, y);
98 rngstep32 (a>>16, a, b, mm, m, m2, r, x, y);
110 u32 a##n, b##n, c##n, x##n, y##n, * m##n, * mm##n, * m2##n, * r##n, * mend##n 118 mm##n = ctx[(n)].memory; \ 119 r##n = results + (n) * ISAAC_SIZE; \ 124 mend##n = m2##n = mm##n + ARRAY_LEN (ctx[(n)].memory) / 2; \ 134 rngstep32 (a0<<13, a0, b0, mm0, m0, m20, r0, x0, y0);
135 rngstep32 (a1<<13, a1, b1, mm1, m1, m21, r1, x1, y1);
136 rngstep32 (a0>>6 , a0, b0, mm0, m0, m20, r0, x0, y0);
137 rngstep32 (a1>>6 , a1, b1, mm1, m1, m21, r1, x1, y1);
138 rngstep32 (a0<<2 , a0, b0, mm0, m0, m20, r0, x0, y0);
139 rngstep32 (a1<<2 , a1, b1, mm1, m1, m21, r1, x1, y1);
140 rngstep32 (a0>>16, a0, b0, mm0, m0, m20, r0, x0, y0);
141 rngstep32 (a1>>16, a1, b1, mm1, m1, m21, r1, x1, y1);
148 rngstep32 (a0<<13, a0, b0, mm0, m0, m20, r0, x0, y0);
149 rngstep32 (a1<<13, a1, b1, mm1, m1, m21, r1, x1, y1);
150 rngstep32 (a0>>6 , a0, b0, mm0, m0, m20, r0, x0, y0);
151 rngstep32 (a1>>6 , a1, b1, mm1, m1, m21, r1, x1, y1);
152 rngstep32 (a0<<2 , a0, b0, mm0, m0, m20, r0, x0, y0);
153 rngstep32 (a1<<2 , a1, b1, mm1, m1, m21, r1, x1, y1);
154 rngstep32 (a0>>16, a0, b0, mm0, m0, m20, r0, x0, y0);
155 rngstep32 (a1>>16, a1, b1, mm1, m1, m21, r1, x1, y1);
166 #define mix32(a,b,c,d,e,f,g,h) \ 168 a^=b<<11; d+=a; b+=c; \ 169 b^=c>>2; e+=b; c+=d; \ 170 c^=d<<8; f+=c; d+=e; \ 171 d^=e>>16; g+=d; e+=f; \ 172 e^=f<<10; h+=e; f+=g; \ 173 f^=g>>4; a+=f; g+=h; \ 174 g^=h<<8; b+=g; h+=a; \ 175 h^=a>>9; c+=h; a+=b; \ 181 u32 a, b, c, d, e, f, g, h, * m, * r;
183 ctx->
a = ctx->
b = ctx->
c = 0;
187 a = b = c = d = e = f = g = h = 0x9e3779b9;
189 for (i = 0; i < 4; ++
i)
190 mix32(a,b,c,d,e,f,g,h);
195 a+=r[
i ]; b+=r[i+1]; c+=r[i+2]; d+=r[i+3];
196 e+=r[i+4]; f+=r[i+5]; g+=r[i+6]; h+=r[i+7];
197 mix32(a,b,c,d,e,f,g,h);
198 m[
i ]=
a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
199 m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
205 a+=m[
i ]; b+=m[i+1]; c+=m[i+2]; d+=m[i+3];
206 e+=m[i+4]; f+=m[i+5]; g+=m[i+6]; h+=m[i+7];
207 mix32(a,b,c,d,e,f,g,h);
208 m[
i ]=
a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
209 m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
216 #define ind64(mm,x) (*(u64 *)((u8 *)(mm) + ((x) & ((ISAAC_SIZE-1)<<3)))) 217 #define rngstep64(mix,a,b,mm,m,m2,r,x,y) \ 220 a = (mix) + *(m2++); \ 221 *(m++) = y = ind64(mm,x) + a + b; \ 222 *(r++) = b = ind64(mm,y>>ISAAC_LOG2_SIZE) + x; \ 227 u64 a, b, c, x,
y, * m, * mm, * m2, * r, * mend;
240 rngstep64 (~(a^(a<<21)), a, b, mm, m, m2, r, x, y);
241 rngstep64 ( a^(a>>5) , a, b, mm, m, m2, r, x, y);
242 rngstep64 ( a^(a<<12) , a, b, mm, m, m2, r, x, y);
243 rngstep64 ( a^(a>>33) , a, b, mm, m, m2, r, x, y);
249 rngstep64 (~(a^(a<<21)), a, b, mm, m, m2, r, x, y);
250 rngstep64 ( a^(a>>5) , a, b, mm, m, m2, r, x, y);
251 rngstep64 ( a^(a<<12) , a, b, mm, m, m2, r, x, y);
252 rngstep64 ( a^(a>>33) , a, b, mm, m, m2, r, x, y);
264 u64 a##n, b##n, c##n, x##n, y##n, * m##n, * mm##n, * m2##n, * r##n, * mend##n 272 mm##n = ctx[(n)].memory; \ 273 r##n = results + (n) * ISAAC_SIZE; \ 278 mend##n = m2##n = mm##n + ARRAY_LEN (ctx[(n)].memory) / 2; \ 290 rngstep64 (~(a0^(a0<<21)), a0, b0, mm0, m0, m20, r0, x0, y0);
291 rngstep64 (~(a1^(a1<<21)), a1, b1, mm1, m1, m21, r1, x1, y1);
292 rngstep64 ( a0^(a0>>5) , a0, b0, mm0, m0, m20, r0, x0, y0);
293 rngstep64 ( a1^(a1>>5) , a1, b1, mm1, m1, m21, r1, x1, y1);
294 rngstep64 ( a0^(a0<<12) , a0, b0, mm0, m0, m20, r0, x0, y0);
295 rngstep64 ( a1^(a1<<12) , a1, b1, mm1, m1, m21, r1, x1, y1);
296 rngstep64 ( a0^(a0>>33) , a0, b0, mm0, m0, m20, r0, x0, y0);
297 rngstep64 ( a1^(a1>>33) , a1, b1, mm1, m1, m21, r1, x1, y1);
304 rngstep64 (~(a0^(a0<<21)), a0, b0, mm0, m0, m20, r0, x0, y0);
305 rngstep64 (~(a1^(a1<<21)), a1, b1, mm1, m1, m21, r1, x1, y1);
306 rngstep64 ( a0^(a0>>5) , a0, b0, mm0, m0, m20, r0, x0, y0);
307 rngstep64 ( a1^(a1>>5) , a1, b1, mm1, m1, m21, r1, x1, y1);
308 rngstep64 ( a0^(a0<<12) , a0, b0, mm0, m0, m20, r0, x0, y0);
309 rngstep64 ( a1^(a1<<12) , a1, b1, mm1, m1, m21, r1, x1, y1);
310 rngstep64 ( a0^(a0>>33) , a0, b0, mm0, m0, m20, r0, x0, y0);
311 rngstep64 ( a1^(a1>>33) , a1, b1, mm1, m1, m21, r1, x1, y1);
322 #define mix64(a,b,c,d,e,f,g,h) \ 324 a-=e; f^=h>>9; h+=a; \ 325 b-=f; g^=a<<9; a+=b; \ 326 c-=g; h^=b>>23; b+=c; \ 327 d-=h; a^=c<<15; c+=d; \ 328 e-=a; b^=d>>14; d+=e; \ 329 f-=b; c^=e<<20; e+=f; \ 330 g-=c; d^=f>>17; f+=g; \ 331 h-=d; e^=g<<14; g+=h; \ 337 u64 a, b, c, d, e, f, g, h, * m, * r;
339 ctx->
a = ctx->
b = ctx->
c = 0;
343 a = b = c = d = e = f = g = h = 0x9e3779b97f4a7c13LL;
346 mix64(a,b,c,d,e,f,g,h);
350 a+=r[
i ]; b+=r[i+1]; c+=r[i+2]; d+=r[i+3];
351 e+=r[i+4]; f+=r[i+5]; g+=r[i+6]; h+=r[i+7];
352 mix64(a,b,c,d,e,f,g,h);
353 m[
i ]=
a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
354 m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
360 a+=m[
i ]; b+=m[i+1]; c+=m[i+2]; d+=m[i+3];
361 e+=m[i+4]; f+=m[i+5]; g+=m[i+6]; h+=m[i+7];
362 mix64(a,b,c,d,e,f,g,h);
363 m[
i ]=
a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
364 m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
sll srl srl sll sra u16x4 i
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
void isaac_init(isaac_t *ctx, uword *results)
add_epi add_epi sub_epi sub_epi adds_epu subs_epu i16x8 y
void isaac2(isaac_t *ctx, uword *results)
void isaac(isaac_t *ctx, uword *results)