miek/jenkins-opencl

Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

78 lines (68 sloc) 1.858 kb
 #include #include #define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) #define mix(a,b,c) \ { \ a -= c; a ^= rot(c, 4); c += b; \ b -= a; b ^= rot(a, 6); a += c; \ c -= b; c ^= rot(b, 8); b += a; \ a -= c; a ^= rot(c,16); c += b; \ b -= a; b ^= rot(a,19); a += c; \ c -= b; c ^= rot(b, 4); b += a; \ } #define final(a,b,c) \ { \ c ^= b; c -= rot(b,14); \ a ^= c; a -= rot(c,11); \ b ^= a; b -= rot(a,25); \ c ^= b; c -= rot(b,16); \ a ^= c; a -= rot(c,4); \ b ^= a; b -= rot(a,14); \ c ^= b; c -= rot(b,24); \ } int hashlittle(const char *k, int length) { unsigned int a,b,c; /* Set up the internal state */ a = b = c = 0xDEADBEEF + ((unsigned int)length);// + initval; while (length > 12) { a += k[0]; a += ((unsigned int)k[1])<<8; a += ((unsigned int)k[2])<<16; a += ((unsigned int)k[3])<<24; b += k[4]; b += ((unsigned int)k[5])<<8; b += ((unsigned int)k[6])<<16; b += ((unsigned int)k[7])<<24; c += k[8]; c += ((unsigned int)k[9])<<8; c += ((unsigned int)k[10])<<16; c += ((unsigned int)k[11])<<24; mix(a,b,c); length -= 12; k += 12; } /*-------------------------------- last block: affect all 32 bits of (c) */ switch(length) /* all the case statements fall through */ { case 12: c+=((unsigned int)k[11])<<24; case 11: c+=((unsigned int)k[10])<<16; case 10: c+=((unsigned int)k[9])<<8; case 9 : c+=k[8]; case 8 : b+=((unsigned int)k[7])<<24; case 7 : b+=((unsigned int)k[6])<<16; case 6 : b+=((unsigned int)k[5])<<8; case 5 : b+=k[4]; case 4 : a+=((unsigned int)k[3])<<24; case 3 : a+=((unsigned int)k[2])<<16; case 2 : a+=((unsigned int)k[1])<<8; case 1 : a+=k[0]; break; case 0 : return c; } final(a,b,c); return c; } int main(int argc, char *argv[]) { printf("0x%X\n", hashlittle(argv[1], strlen(argv[1]))); }
Something went wrong with that request. Please try again.