ia64/linux-2.6.18-xen.hg

view Documentation/pcmcia/crc32hash.c @ 524:7f8b544237bf

netfront: Allow netfront in domain 0.

This is useful if your physical network device is in a utility domain.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 15 15:18:58 2008 +0100 (2008-04-15)
parents 831230e53067
children
line source
1 /* crc32hash.c - derived from linux/lib/crc32.c, GNU GPL v2 */
2 /* Usage example:
3 $ ./crc32hash "Dual Speed"
4 */
6 #include <string.h>
7 #include <stdio.h>
8 #include <ctype.h>
9 #include <stdlib.h>
11 unsigned int crc32(unsigned char const *p, unsigned int len)
12 {
13 int i;
14 unsigned int crc = 0;
15 while (len--) {
16 crc ^= *p++;
17 for (i = 0; i < 8; i++)
18 crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
19 }
20 return crc;
21 }
23 int main(int argc, char **argv) {
24 unsigned int result;
25 if (argc != 2) {
26 printf("no string passed as argument\n");
27 return -1;
28 }
29 result = crc32(argv[1], strlen(argv[1]));
30 printf("0x%x\n", result);
31 return 0;
32 }