diff options
author | jb <jb@FreeBSD.org> | 1998-03-10 05:03:49 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 1998-03-10 05:03:49 +0000 |
commit | 3993727e630e0d7a6b7efef91fa8eb08cf4b62bf (patch) | |
tree | 5a3faab89b17f643a7a86dfb08ce976dd9534067 /usr.bin/cksum | |
parent | 757dddeeb5cd4b11dbbab454753dcdef1458bb26 (diff) | |
download | FreeBSD-src-3993727e630e0d7a6b7efef91fa8eb08cf4b62bf.zip FreeBSD-src-3993727e630e0d7a6b7efef91fa8eb08cf4b62bf.tar.gz |
cksum does a 32-bit checksum, so it needs to use u_int32_t variables,
not u_long. With this change, cksum stops core dumping on alpha (not
a good sign!) and actually computes the same values as it does on i386.
Diffstat (limited to 'usr.bin/cksum')
-rw-r--r-- | usr.bin/cksum/cksum.c | 8 | ||||
-rw-r--r-- | usr.bin/cksum/crc.c | 8 | ||||
-rw-r--r-- | usr.bin/cksum/crc32.c | 10 | ||||
-rw-r--r-- | usr.bin/cksum/extern.h | 14 | ||||
-rw-r--r-- | usr.bin/cksum/print.c | 12 | ||||
-rw-r--r-- | usr.bin/cksum/sum1.c | 4 | ||||
-rw-r--r-- | usr.bin/cksum/sum2.c | 4 |
7 files changed, 31 insertions, 29 deletions
diff --git a/usr.bin/cksum/cksum.c b/usr.bin/cksum/cksum.c index 1a4d207..dbe488c 100644 --- a/usr.bin/cksum/cksum.c +++ b/usr.bin/cksum/cksum.c @@ -45,7 +45,7 @@ static const char copyright[] = static char sccsid[] = "@(#)cksum.c 8.2 (Berkeley) 4/28/95"; #endif static const char rcsid[] = - "$Id: cksum.c,v 1.7 1997/11/09 05:35:26 obrien Exp $"; + "$Id: cksum.c,v 1.8 1997/11/09 05:47:55 obrien Exp $"; #endif /* not lint */ #include <sys/cdefs.h> @@ -69,10 +69,10 @@ main(argc, argv) char **argv; { register int ch, fd, rval; - u_long len, val; + u_int32_t len, val; char *fn, *p; - int (*cfncn) __P((int, unsigned long *, unsigned long *)); - void (*pfncn) __P((char *, unsigned long, unsigned long)); + int (*cfncn) __P((int, u_int32_t *, u_int32_t *)); + void (*pfncn) __P((char *, u_int32_t, u_int32_t)); if ((p = rindex(argv[0], '/')) == NULL) p = argv[0]; diff --git a/usr.bin/cksum/crc.c b/usr.bin/cksum/crc.c index 2a5eb6d..3526395 100644 --- a/usr.bin/cksum/crc.c +++ b/usr.bin/cksum/crc.c @@ -41,7 +41,7 @@ static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 6/17/93"; #include <sys/types.h> #include <unistd.h> -static u_long crctab[] = { +static const u_int32_t crctab[] = { 0x0, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, @@ -102,16 +102,16 @@ static u_long crctab[] = { * locations to store the crc and the number of bytes read. It returns 0 on * success and 1 on failure. Errno is set on failure. */ -u_long crc_total = ~0; /* The crc over a number of files. */ +u_int32_t crc_total = ~0; /* The crc over a number of files. */ int crc(fd, cval, clen) register int fd; - u_long *cval, *clen; + u_int32_t *cval, *clen; { register u_char *p; register int nr; - register u_long crc, len; + register u_int32_t crc, len; u_char buf[16 * 1024]; #define COMPUTE(var, ch) (var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)] diff --git a/usr.bin/cksum/crc32.c b/usr.bin/cksum/crc32.c index 51aff76..1cc29a2 100644 --- a/usr.bin/cksum/crc32.c +++ b/usr.bin/cksum/crc32.c @@ -11,13 +11,15 @@ * Spencer Garrett <srg@quick.com> */ +#include <sys/types.h> + #define CRC(crc, ch) (crc = (crc >> 8) ^ crctab[(crc ^ (ch)) & 0xff]) /* generated using the AUTODIN II polynomial * x^32 + x^26 + x^23 + x^22 + x^16 + * x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + 1 */ -unsigned long crctab[256] = { +static const u_int32_t crctab[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, @@ -88,14 +90,14 @@ unsigned long crctab[256] = { #include <sys/types.h> #include <unistd.h> -u_long crc32_total = 0 ; +u_int32_t crc32_total = 0 ; int crc32(fd, cval, clen) register int fd; - u_long *cval, *clen; + u_int32_t *cval, *clen; { - u_long crc = ~0; + u_int32_t crc = ~0; char buf[BUFSIZ], *p ; int len, nr ; diff --git a/usr.bin/cksum/extern.h b/usr.bin/cksum/extern.h index 2d43490..cee3f24 100644 --- a/usr.bin/cksum/extern.h +++ b/usr.bin/cksum/extern.h @@ -36,11 +36,11 @@ #include <sys/cdefs.h> __BEGIN_DECLS -int crc __P((int, unsigned long *, unsigned long *)); -void pcrc __P((char *, unsigned long, unsigned long)); -void psum1 __P((char *, unsigned long, unsigned long)); -void psum2 __P((char *, unsigned long, unsigned long)); -int csum1 __P((int, unsigned long *, unsigned long *)); -int csum2 __P((int, unsigned long *, unsigned long *)); -int crc32 __P((int, unsigned long *, unsigned long *)); +int crc __P((int, u_int32_t *, u_int32_t *)); +void pcrc __P((char *, u_int32_t, u_int32_t)); +void psum1 __P((char *, u_int32_t, u_int32_t)); +void psum2 __P((char *, u_int32_t, u_int32_t)); +int csum1 __P((int, u_int32_t *, u_int32_t *)); +int csum2 __P((int, u_int32_t *, u_int32_t *)); +int crc32 __P((int, u_int32_t *, u_int32_t *)); __END_DECLS diff --git a/usr.bin/cksum/print.c b/usr.bin/cksum/print.c index d0ffeb3..48c38aa 100644 --- a/usr.bin/cksum/print.c +++ b/usr.bin/cksum/print.c @@ -42,9 +42,9 @@ static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 6/6/93"; void pcrc(fn, val, len) char *fn; - u_long val, len; + u_int32_t val, len; { - (void)printf("%lu %lu", val, len); + (void)printf("%lu %lu", (u_long) val, (u_long) len); if (fn) (void)printf(" %s", fn); (void)printf("\n"); @@ -53,9 +53,9 @@ pcrc(fn, val, len) void psum1(fn, val, len) char *fn; - u_long val, len; + u_int32_t val, len; { - (void)printf("%lu %lu", val, (len + 1023) / 1024); + (void)printf("%lu %lu", (u_long) val, (u_long) (len + 1023) / 1024); if (fn) (void)printf(" %s", fn); (void)printf("\n"); @@ -64,9 +64,9 @@ psum1(fn, val, len) void psum2(fn, val, len) char *fn; - u_long val, len; + u_int32_t val, len; { - (void)printf("%lu %lu", val, (len + 511) / 512); + (void)printf("%lu %lu", (u_long) val, (u_long) (len + 511) / 512); if (fn) (void)printf(" %s", fn); (void)printf("\n"); diff --git a/usr.bin/cksum/sum1.c b/usr.bin/cksum/sum1.c index 19eeebe..1975ee2 100644 --- a/usr.bin/cksum/sum1.c +++ b/usr.bin/cksum/sum1.c @@ -41,9 +41,9 @@ static char sccsid[] = "@(#)sum1.c 8.1 (Berkeley) 6/6/93"; int csum1(fd, cval, clen) register int fd; - u_long *cval, *clen; + u_int32_t *cval, *clen; { - register u_long total; + register u_int32_t total; register int nr; register u_int crc; register u_char *p; diff --git a/usr.bin/cksum/sum2.c b/usr.bin/cksum/sum2.c index c54d88e..7922050 100644 --- a/usr.bin/cksum/sum2.c +++ b/usr.bin/cksum/sum2.c @@ -41,9 +41,9 @@ static char sccsid[] = "@(#)sum2.c 8.1 (Berkeley) 6/6/93"; int csum2(fd, cval, clen) register int fd; - u_long *cval, *clen; + u_int32_t *cval, *clen; { - register u_long crc, total; + register u_int32_t crc, total; register int nr; register u_char *p; u_char buf[8192]; |